@onerjs/core 8.44.4 → 8.44.6
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/Bones/skeleton.d.ts +6 -0
- package/Bones/skeleton.js +10 -0
- package/Bones/skeleton.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +2 -2
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/abstractEngine.js +19 -9
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.js +5 -1
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/serialization.js +0 -1
- package/FlowGraph/serialization.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.d.ts +5 -0
- package/Materials/Textures/equiRectangularCubeTexture.js +19 -0
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/materialHelper.functions.js +3 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Meshes/abstractMesh.js +9 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +12 -8
- package/Meshes/mesh.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -0
- package/Particles/solidParticleSystem.js +32 -2
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +5 -3
- package/Physics/v2/Plugins/havokPlugin.js +9 -5
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +5 -3
- package/Physics/v2/physicsBody.js +7 -5
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +9 -4
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +7 -4
- package/Rendering/edgesRenderer.js.map +1 -1
- package/package.json +1 -1
- package/Meshes/Compression/test/integration/draco.test.d.ts +0 -1
- package/Meshes/Compression/test/integration/draco.test.js +0 -30
- package/Meshes/Compression/test/integration/draco.test.js.map +0 -1
|
@@ -344,14 +344,16 @@ export declare class PhysicsBody {
|
|
|
344
344
|
getGeometry(): object;
|
|
345
345
|
/**
|
|
346
346
|
* Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody
|
|
347
|
+
* @param instanceIndex - optionally, the index of the instance in the body
|
|
347
348
|
* @returns Observable
|
|
348
349
|
*/
|
|
349
|
-
getCollisionObservable(): Observable<IPhysicsCollisionEvent>;
|
|
350
|
+
getCollisionObservable(instanceIndex?: number): Observable<IPhysicsCollisionEvent>;
|
|
350
351
|
/**
|
|
351
352
|
* Returns an observable that will be notified when the body has finished colliding with another body
|
|
352
|
-
* @
|
|
353
|
+
* @param instanceIndex - optionally, the index of the instance in the body
|
|
354
|
+
* @returns Observable
|
|
353
355
|
*/
|
|
354
|
-
getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent>;
|
|
356
|
+
getCollisionEndedObservable(instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;
|
|
355
357
|
/**
|
|
356
358
|
* Enable or disable collision callback for this PhysicsBody.
|
|
357
359
|
* @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable
|
|
@@ -443,17 +443,19 @@ export class PhysicsBody {
|
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
445
|
* Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody
|
|
446
|
+
* @param instanceIndex - optionally, the index of the instance in the body
|
|
446
447
|
* @returns Observable
|
|
447
448
|
*/
|
|
448
|
-
getCollisionObservable() {
|
|
449
|
-
return this._physicsPlugin.getCollisionObservable(this);
|
|
449
|
+
getCollisionObservable(instanceIndex) {
|
|
450
|
+
return this._physicsPlugin.getCollisionObservable(this, instanceIndex);
|
|
450
451
|
}
|
|
451
452
|
/**
|
|
452
453
|
* Returns an observable that will be notified when the body has finished colliding with another body
|
|
453
|
-
* @
|
|
454
|
+
* @param instanceIndex - optionally, the index of the instance in the body
|
|
455
|
+
* @returns Observable
|
|
454
456
|
*/
|
|
455
|
-
getCollisionEndedObservable() {
|
|
456
|
-
return this._physicsPlugin.getCollisionEndedObservable(this);
|
|
457
|
+
getCollisionEndedObservable(instanceIndex) {
|
|
458
|
+
return this._physicsPlugin.getCollisionEndedObservable(this, instanceIndex);
|
|
457
459
|
}
|
|
458
460
|
/**
|
|
459
461
|
* Enable or disable collision callback for this PhysicsBody.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAW,cAAc,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAmBD;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAxE5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAC7C;;WAEG;QACK,6BAAwB,GAAY,KAAK,CAAC;QAkBlD;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QASrB,gBAAW,GAAG,KAAK,CAAC;QAEpB,WAAM,GAA2B,IAAI,CAAC;QAEtC,iB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AAgC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType, PhysicsPrestepType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"../../Bones/bone\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for. If body is instanced but instanceIndex is undefined, the motion type will be set for all instances.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = instanceIndex === undefined && motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a torque to the physics body.\r\n *\r\n * @param torque The torque vector.\r\n * @param instanceIndex For a instanced body, the instance to where the torque should be applied. If not specified, the torque is applied to all instances.\r\n *\r\n * This method is useful for applying a torque to a physics body, which can be used to simulate rotational forces such as motors,\r\n * angular momentum, and rotational dynamics. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyTorque(torque: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyTorque(this, torque, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAW,cAAc,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAmBD;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAxE5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAC7C;;WAEG;QACK,6BAAwB,GAAY,KAAK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AqE;QACrE,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType, PhysicsPrestepType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"../../Bones/bone\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = motionType == PhysicsMotionType.STATIC;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for. If body is instanced but instanceIndex is undefined, the motion type will be set for all instances.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = instanceIndex === undefined && motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a torque to the physics body.\r\n *\r\n * @param torque The torque vector.\r\n * @param instanceIndex For a instanced body, the instance to where the torque should be applied. If not specified, the torque is applied to all instances.\r\n *\r\n * This method is useful for applying a torque to a physics body, which can be used to simulate rotational forces such as motors,\r\n * angular momentum, and rotational dynamics. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyTorque(torque: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyTorque(this, torque, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(instanceIndex?: number): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionEndedObservable(instanceIndex?: number): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|
|
@@ -50,6 +50,7 @@ Object.defineProperty(AbstractMesh.prototype, "showBoundingBox", {
|
|
|
50
50
|
configurable: true,
|
|
51
51
|
});
|
|
52
52
|
const TempMatrix = Matrix.Identity();
|
|
53
|
+
const TempMatrix2 = new Matrix();
|
|
53
54
|
const TempVec1 = new Vector3();
|
|
54
55
|
const TempVec2 = new Vector3();
|
|
55
56
|
// `Matrix.asArray` returns its internal array, so it can be directly updated
|
|
@@ -491,10 +492,14 @@ export class BoundingBoxRenderer {
|
|
|
491
492
|
m[10] = diff._z; // Scale Z
|
|
492
493
|
m[11] = median._z; // Translate Z
|
|
493
494
|
const offset = instancesCount * 16;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
495
|
+
// Multiply into Float64 temp matrix, subtract offset in Float64, then copy to Float32 buffer
|
|
496
|
+
// to preserve precision at large coordinates.
|
|
497
|
+
const resultM = TempMatrix2.asArray();
|
|
498
|
+
TempMatrix.multiplyToArray(boundingBox.getWorldMatrix(), resultM, 0);
|
|
499
|
+
resultM[12] -= floatingOriginOffset.x;
|
|
500
|
+
resultM[13] -= floatingOriginOffset.y;
|
|
501
|
+
resultM[14] -= floatingOriginOffset.z;
|
|
502
|
+
TempMatrix2.copyToArray(matrices, offset);
|
|
498
503
|
instancesCount++;
|
|
499
504
|
}
|
|
500
505
|
const engine = this.scene.getEngine();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundingBoxRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/boundingBoxRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,SAAS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,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import { Scene } from \"../scene\";\r\nimport { Buffer, VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { ISceneComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { BoundingBox } from \"../Culling/boundingBox\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport { CreateBoxVertexData } from \"../Meshes/Builders/boxBuilder\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { _RetryWithInterval } from \"../Misc/timingTools\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\ndeclare module \"../scene\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Scene {\r\n /** @internal (Backing field) */\r\n _boundingBoxRenderer: BoundingBoxRenderer;\r\n\r\n /** @internal (Backing field) */\r\n _forceShowBoundingBoxes: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if all bounding boxes must be rendered\r\n */\r\n forceShowBoundingBoxes: boolean;\r\n\r\n /**\r\n * Gets the bounding box renderer associated with the scene\r\n * @returns a BoundingBoxRenderer\r\n */\r\n getBoundingBoxRenderer(): BoundingBoxRenderer;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"forceShowBoundingBoxes\", {\r\n get: function (this: Scene) {\r\n return this._forceShowBoundingBoxes || false;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n this._forceShowBoundingBoxes = value;\r\n // Lazyly creates a BB renderer if needed.\r\n if (value) {\r\n this.getBoundingBoxRenderer();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.getBoundingBoxRenderer = function (): BoundingBoxRenderer {\r\n if (!this._boundingBoxRenderer) {\r\n this._boundingBoxRenderer = new BoundingBoxRenderer(this);\r\n }\r\n\r\n return this._boundingBoxRenderer;\r\n};\r\n\r\ndeclare module \"../Meshes/abstractMesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractMesh {\r\n /** @internal (Backing field) */\r\n _showBoundingBox: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)\r\n */\r\n showBoundingBox: boolean;\r\n }\r\n}\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"showBoundingBox\", {\r\n get: function (this: AbstractMesh) {\r\n return this._showBoundingBox || false;\r\n },\r\n set: function (this: AbstractMesh, value: boolean) {\r\n this._showBoundingBox = value;\r\n // Lazyly creates a BB renderer if needed.\r\n if (value) {\r\n this.getScene().getBoundingBoxRenderer();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nconst TempMatrix = Matrix.Identity();\r\nconst TempVec1 = new Vector3();\r\nconst TempVec2 = new Vector3();\r\n// `Matrix.asArray` returns its internal array, so it can be directly updated\r\nconst TempMatrixArray = TempMatrix.asArray();\r\n\r\n// BoundingBox copies from it, so it's safe to reuse vectors here\r\nconst DummyBoundingBox = new BoundingBox(TempVec1, TempVec1);\r\n\r\n/**\r\n * Component responsible of rendering the bounding box of the meshes in a scene.\r\n * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties\r\n */\r\nexport class BoundingBoxRenderer implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_BOUNDINGBOXRENDERER;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Color of the bounding box lines placed in front of an object\r\n */\r\n public frontColor = new Color3(1, 1, 1);\r\n /**\r\n * Color of the bounding box lines placed behind an object\r\n */\r\n public backColor = new Color3(0.1, 0.1, 0.1);\r\n /**\r\n * Defines if the renderer should show the back lines or not\r\n */\r\n public showBackLines = true;\r\n\r\n /**\r\n * Observable raised before rendering a bounding box\r\n * When {@link BoundingBoxRenderer.useInstances} enabled,\r\n * this would only be triggered once for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n */\r\n public onBeforeBoxRenderingObservable = new Observable<BoundingBox>();\r\n\r\n /**\r\n * Observable raised after rendering a bounding box\r\n * When {@link BoundingBoxRenderer.useInstances} enabled,\r\n * this would only be triggered once for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n */\r\n public onAfterBoxRenderingObservable = new Observable<BoundingBox>();\r\n\r\n /**\r\n * Observable raised after resources are created\r\n */\r\n public onResourcesReadyObservable = new Observable<BoundingBoxRenderer>();\r\n\r\n /**\r\n * When false, no bounding boxes will be rendered\r\n */\r\n public enabled = true;\r\n\r\n /** Shader language used by the renderer */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language used in this renderer.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public renderList = new SmartArray<BoundingBox>(32);\r\n\r\n private _colorShader: ShaderMaterial;\r\n private _colorShaderForOcclusionQuery: ShaderMaterial;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: DataBuffer;\r\n private _fillIndexBuffer: Nullable<DataBuffer> = null;\r\n private _fillIndexData: Nullable<IndicesArray> = null;\r\n private _uniformBufferFront: UniformBuffer;\r\n private _uniformBufferBack: UniformBuffer;\r\n private _renderPassIdForOcclusionQuery: number;\r\n /**\r\n * Internal buffer for instanced rendering\r\n */\r\n private _matrixBuffer: Nullable<Buffer> = null;\r\n private _matrices: Nullable<Float32Array> = null;\r\n\r\n /**\r\n * Internal state of whether instanced rendering enabled\r\n */\r\n protected _useInstances = false;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Instantiates a new bounding box renderer in a scene.\r\n * @param scene the scene the renderer renders in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n\r\n const engine = this.scene.getEngine();\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n scene._addComponent(this);\r\n this._uniformBufferFront = new UniformBuffer(this.scene.getEngine(), undefined, undefined, \"BoundingBoxRendererFront\", true);\r\n this._buildUniformLayout(this._uniformBufferFront);\r\n this._uniformBufferBack = new UniformBuffer(this.scene.getEngine(), undefined, undefined, \"BoundingBoxRendererBack\", true);\r\n this._buildUniformLayout(this._uniformBufferBack);\r\n }\r\n\r\n private _buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"color\", 4);\r\n ubo.addUniform(\"world\", 16);\r\n ubo.addUniform(\"viewProjection\", 16);\r\n ubo.addUniform(\"viewProjectionR\", 16);\r\n ubo.create();\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._beforeEvaluateActiveMeshStage.registerStep(SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);\r\n\r\n this.scene._preActiveMeshStage.registerStep(SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh);\r\n\r\n this.scene._evaluateSubMeshStage.registerStep(SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);\r\n\r\n this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);\r\n }\r\n\r\n /**\r\n * Checks if the renderer is ready asynchronously.\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)\r\n * @returns The promise that resolves when the renderer is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n this._prepareResources();\r\n return await new Promise((resolve) => {\r\n _RetryWithInterval(\r\n () => {\r\n return this._colorShader.isReady();\r\n },\r\n () => {\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n if (!isTimeout) {\r\n Logger.Error(\"BoundingBoxRenderer: An unexpected error occurred while waiting for the renderer to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(`BoundingBoxRenderer: Timeout while waiting for the renderer to be ready.`);\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /** @internal */\r\n public _evaluateSubMesh(mesh: AbstractMesh, subMesh: SubMesh): void {\r\n if (mesh.showSubMeshesBoundingBox) {\r\n const boundingInfo = subMesh.getBoundingInfo();\r\n if (boundingInfo !== null && boundingInfo !== undefined) {\r\n boundingInfo.boundingBox._tag = mesh.renderingGroupId;\r\n this.renderList.push(boundingInfo.boundingBox);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _preActiveMesh(mesh: AbstractMesh): void {\r\n if (mesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {\r\n const boundingInfo = mesh.getBoundingInfo();\r\n boundingInfo.boundingBox._tag = mesh.renderingGroupId;\r\n this.renderList.push(boundingInfo.boundingBox);\r\n }\r\n }\r\n\r\n private _prepareResources(): void {\r\n if (this._colorShader) {\r\n return;\r\n }\r\n\r\n this._colorShader = new ShaderMaterial(\r\n \"colorShader\",\r\n this.scene,\r\n \"boundingBoxRenderer\",\r\n {\r\n attributes: [VertexBuffer.PositionKind, \"world0\", \"world1\", \"world2\", \"world3\"],\r\n\r\n uniforms: [\"world\", \"viewProjection\", \"viewProjectionR\", \"color\"],\r\n uniformBuffers: [\"BoundingBoxRenderer\"],\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/boundingBoxRenderer.vertex\"), import(\"../ShadersWGSL/boundingBoxRenderer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/boundingBoxRenderer.vertex\"), import(\"../Shaders/boundingBoxRenderer.fragment\")]);\r\n }\r\n },\r\n },\r\n false\r\n );\r\n this._colorShader.setDefine(\"INSTANCES\", this._useInstances);\r\n this._colorShader.doNotSerialize = true;\r\n\r\n this._colorShader.reservedDataStore = {\r\n hidden: true,\r\n };\r\n\r\n this._colorShaderForOcclusionQuery = new ShaderMaterial(\r\n \"colorShaderOccQuery\",\r\n this.scene,\r\n \"boundingBoxRenderer\",\r\n {\r\n attributes: [VertexBuffer.PositionKind],\r\n uniforms: [\"world\", \"viewProjection\", \"viewProjectionR\", \"color\"],\r\n uniformBuffers: [\"BoundingBoxRenderer\"],\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/boundingBoxRenderer.vertex\"), import(\"../ShadersWGSL/boundingBoxRenderer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/boundingBoxRenderer.vertex\"), import(\"../Shaders/boundingBoxRenderer.fragment\")]);\r\n }\r\n },\r\n },\r\n true\r\n );\r\n this._colorShaderForOcclusionQuery.doNotSerialize = true;\r\n\r\n this._colorShaderForOcclusionQuery.reservedDataStore = {\r\n hidden: true,\r\n };\r\n\r\n const engine = this.scene.getEngine();\r\n const boxdata = CreateBoxVertexData({ size: 1.0 });\r\n this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, <FloatArray>boxdata.positions, VertexBuffer.PositionKind, false);\r\n this._createIndexBuffer();\r\n this._fillIndexData = boxdata.indices;\r\n this.onResourcesReadyObservable.notifyObservers(this);\r\n }\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this.scene.getEngine();\r\n this._indexBuffer = engine.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n this._createIndexBuffer();\r\n\r\n if (this._matrixBuffer) {\r\n this._matrixBuffer._rebuild();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public reset(): void {\r\n this.renderList.reset();\r\n }\r\n\r\n /**\r\n * Render the bounding boxes of a specific rendering group\r\n * @param renderingGroupId defines the rendering group to render\r\n */\r\n public render(renderingGroupId: number): void {\r\n if (this.renderList.length === 0 || !this.enabled) {\r\n return;\r\n }\r\n\r\n if (this._useInstances) {\r\n this._renderInstanced(renderingGroupId);\r\n return;\r\n }\r\n\r\n this._prepareResources();\r\n\r\n if (!this._colorShader.isReady()) {\r\n return;\r\n }\r\n\r\n const engine = this.scene.getEngine();\r\n engine.setDepthWrite(false);\r\n\r\n const transformMatrix = this.scene.getTransformMatrix();\r\n\r\n for (let boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {\r\n const boundingBox = this.renderList.data[boundingBoxIndex];\r\n if (boundingBox._tag !== renderingGroupId) {\r\n continue;\r\n }\r\n\r\n this._createWrappersForBoundingBox(boundingBox);\r\n this.onBeforeBoxRenderingObservable.notifyObservers(boundingBox);\r\n\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n const diff = max.subtract(min);\r\n const median = min.add(diff.scale(0.5));\r\n\r\n const worldMatrix = Matrix.Scaling(diff.x, diff.y, diff.z)\r\n .multiply(Matrix.Translation(median.x, median.y, median.z))\r\n .multiply(boundingBox.getWorldMatrix());\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n\r\n if (this.showBackLines) {\r\n const drawWrapperBack = boundingBox._drawWrapperBack ?? this._colorShader._getDrawWrapper();\r\n\r\n this._colorShader._preBind(drawWrapperBack);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());\r\n\r\n // Back\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToLessOrEqual();\r\n } else {\r\n engine.setDepthFunctionToGreaterOrEqual();\r\n }\r\n this._uniformBufferBack.bindToEffect(drawWrapperBack.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferBack.updateColor4(\"color\", this.backColor, 1);\r\n this._uniformBufferBack.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferBack.updateMatrix(\"viewProjection\", transformMatrix);\r\n this._uniformBufferBack.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24);\r\n }\r\n\r\n const drawWrapperFront = boundingBox._drawWrapperFront ?? this._colorShader._getDrawWrapper();\r\n\r\n this._colorShader._preBind(drawWrapperFront);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());\r\n\r\n // Front\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n this._uniformBufferFront.bindToEffect(drawWrapperFront.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferFront.updateColor4(\"color\", this.frontColor, 1);\r\n this._uniformBufferFront.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferFront.updateMatrix(\"viewProjection\", transformMatrix);\r\n this._uniformBufferFront.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24);\r\n\r\n this.onAfterBoxRenderingObservable.notifyObservers(boundingBox);\r\n }\r\n this._colorShader.unbind();\r\n engine.setDepthFunctionToLessOrEqual();\r\n engine.setDepthWrite(true);\r\n }\r\n\r\n private _createWrappersForBoundingBox(boundingBox: BoundingBox | BoundingBoxRenderer): void {\r\n if (!boundingBox._drawWrapperFront) {\r\n const engine = this.scene.getEngine();\r\n\r\n boundingBox._drawWrapperFront = new DrawWrapper(engine);\r\n boundingBox._drawWrapperBack = new DrawWrapper(engine);\r\n\r\n boundingBox._drawWrapperFront.setEffect(this._colorShader.getEffect());\r\n boundingBox._drawWrapperBack.setEffect(this._colorShader.getEffect());\r\n }\r\n }\r\n\r\n /**\r\n * In case of occlusion queries, we can render the occlusion bounding box through this method\r\n * @param mesh Define the mesh to render the occlusion bounding box for\r\n */\r\n public renderOcclusionBoundingBox(mesh: AbstractMesh): void {\r\n const engine = this.scene.getEngine();\r\n\r\n if (this._renderPassIdForOcclusionQuery === undefined) {\r\n this._renderPassIdForOcclusionQuery = engine.createRenderPassId(`Render pass for occlusion query`);\r\n }\r\n\r\n const currentRenderPassId = engine.currentRenderPassId;\r\n\r\n engine.currentRenderPassId = this._renderPassIdForOcclusionQuery;\r\n\r\n this._prepareResources();\r\n\r\n const subMesh = mesh.subMeshes[0];\r\n\r\n if (!this._colorShaderForOcclusionQuery.isReady(mesh, undefined, subMesh) || !mesh.hasBoundingInfo) {\r\n engine.currentRenderPassId = currentRenderPassId;\r\n return;\r\n }\r\n\r\n if (!this._fillIndexBuffer) {\r\n this._fillIndexBuffer = engine.createIndexBuffer(this._fillIndexData!);\r\n }\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n\r\n engine.setDepthWrite(false);\r\n engine.setColorWrite(false);\r\n\r\n const boundingBox = mesh.getBoundingInfo().boundingBox;\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n const diff = max.subtract(min);\r\n const median = min.add(diff.scale(0.5));\r\n\r\n const worldMatrix = Matrix.Scaling(diff.x, diff.y, diff.z)\r\n .multiply(Matrix.Translation(median.x, median.y, median.z))\r\n .multiply(boundingBox.getWorldMatrix());\r\n\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n this._colorShaderForOcclusionQuery._preBind(drawWrapper);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, <Effect>drawWrapper.effect);\r\n\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n\r\n this.scene.resetCachedMaterial();\r\n\r\n this._uniformBufferFront.bindToEffect(drawWrapper.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferFront.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferFront.updateMatrix(\"viewProjection\", this.scene.getTransformMatrix());\r\n this._uniformBufferFront.update();\r\n\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 36);\r\n\r\n this._colorShaderForOcclusionQuery.unbind();\r\n engine.setDepthFunctionToLessOrEqual();\r\n engine.setDepthWrite(true);\r\n engine.setColorWrite(true);\r\n\r\n engine.currentRenderPassId = currentRenderPassId;\r\n }\r\n\r\n /**\r\n * Sets whether to use instanced rendering.\r\n * When not enabled, BoundingBoxRenderer renders in a loop,\r\n * calling engine.drawElementsType for each bounding box in renderList,\r\n * making every bounding box 1 or 2 draw call.\r\n * When enabled, it collects bounding boxes to render,\r\n * and render all boxes in 1 or 2 draw call.\r\n * This could make the rendering with many bounding boxes much faster than not enabled,\r\n * but could result in a difference in rendering result if\r\n * {@link BoundingBoxRenderer.showBackLines} enabled,\r\n * because drawing the black/white part of each box one after the other\r\n * can be different from drawing the black part of all boxes and then the white part.\r\n * Also, when enabled, events of {@link BoundingBoxRenderer.onBeforeBoxRenderingObservable}\r\n * and {@link BoundingBoxRenderer.onAfterBoxRenderingObservable} would only be triggered once\r\n * for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n * @param val whether to use instanced rendering\r\n */\r\n public set useInstances(val: boolean) {\r\n this._useInstances = val;\r\n if (this._colorShader) {\r\n this._colorShader.setDefine(\"INSTANCES\", val);\r\n }\r\n if (!val) {\r\n this._cleanupInstances();\r\n }\r\n }\r\n\r\n public get useInstances(): boolean {\r\n return this._useInstances;\r\n }\r\n\r\n /**\r\n * Instanced render the bounding boxes of a specific rendering group\r\n * @param renderingGroupId defines the rendering group to render\r\n */\r\n private _renderInstanced(renderingGroupId: number): void {\r\n if (this.renderList.length === 0 || !this.enabled) {\r\n return;\r\n }\r\n this._prepareResources();\r\n\r\n if (!this._colorShader.isReady()) {\r\n return;\r\n }\r\n\r\n const colorShader = this._colorShader;\r\n let matrices = this._matrices;\r\n const expectedLength = this.renderList.length * 16;\r\n if (!matrices || matrices.length < expectedLength || matrices.length > expectedLength * 2) {\r\n matrices = new Float32Array(expectedLength);\r\n this._matrices = matrices;\r\n }\r\n\r\n this.onBeforeBoxRenderingObservable.notifyObservers(DummyBoundingBox);\r\n\r\n let instancesCount = 0;\r\n const floatingOriginOffset = this.scene.floatingOriginOffset;\r\n\r\n for (let boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {\r\n const boundingBox = this.renderList.data[boundingBoxIndex];\r\n if (boundingBox._tag !== renderingGroupId) {\r\n continue;\r\n }\r\n\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n\r\n const diff = max.subtractToRef(min, TempVec2);\r\n const median = min.addToRef(diff.scaleToRef(0.5, TempVec1), TempVec1);\r\n\r\n const m = TempMatrixArray;\r\n\r\n // Directly update the matrix values in column-major order\r\n m[0] = diff._x; // Scale X\r\n m[3] = median._x; // Translate X\r\n\r\n m[5] = diff._y; // Scale Y\r\n m[7] = median._y; // Translate Y\r\n\r\n m[10] = diff._z; // Scale Z\r\n m[11] = median._z; // Translate Z\r\n\r\n const offset = instancesCount * 16;\r\n TempMatrix.multiplyToArray(boundingBox.getWorldMatrix(), matrices, offset);\r\n\r\n matrices[offset + 12] -= floatingOriginOffset.x;\r\n matrices[offset + 13] -= floatingOriginOffset.y;\r\n matrices[offset + 14] -= floatingOriginOffset.z;\r\n instancesCount++;\r\n }\r\n\r\n const engine = this.scene.getEngine();\r\n // keeps the original depth function and depth write\r\n const depthFunction = engine.getDepthFunction() ?? Constants.LEQUAL;\r\n const depthWrite = engine.getDepthWrite();\r\n engine.setDepthWrite(false);\r\n const matrixBuffer = this._matrixBuffer;\r\n if (matrixBuffer?.isUpdatable() && matrixBuffer.getData() === matrices) {\r\n matrixBuffer.update(matrices);\r\n } else {\r\n this._createInstanceBuffer(matrices);\r\n }\r\n\r\n this._createWrappersForBoundingBox(this);\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n const transformMatrix = this.scene.getTransformMatrix();\r\n\r\n if (this.showBackLines) {\r\n const drawWrapperBack = this._drawWrapperBack ?? colorShader._getDrawWrapper();\r\n\r\n colorShader._preBind(drawWrapperBack);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, colorShader.getEffect());\r\n\r\n // Back\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToLessOrEqual();\r\n } else {\r\n engine.setDepthFunctionToGreaterOrEqual();\r\n }\r\n const _uniformBufferBack: UniformBuffer = this._uniformBufferBack;\r\n\r\n _uniformBufferBack.bindToEffect(drawWrapperBack.effect!, \"BoundingBoxRenderer\");\r\n _uniformBufferBack.updateColor4(\"color\", this.backColor, 1);\r\n _uniformBufferBack.updateMatrix(\"viewProjection\", transformMatrix);\r\n _uniformBufferBack.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24, instancesCount);\r\n }\r\n\r\n const drawWrapperFront = colorShader._getDrawWrapper();\r\n\r\n colorShader._preBind(drawWrapperFront);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, colorShader.getEffect());\r\n\r\n // Front\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n const _uniformBufferFront: UniformBuffer = this._uniformBufferFront;\r\n _uniformBufferFront.bindToEffect(drawWrapperFront.effect!, \"BoundingBoxRenderer\");\r\n _uniformBufferFront.updateColor4(\"color\", this.frontColor, 1);\r\n _uniformBufferFront.updateMatrix(\"viewProjection\", transformMatrix);\r\n _uniformBufferFront.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24, instancesCount);\r\n\r\n this.onAfterBoxRenderingObservable.notifyObservers(DummyBoundingBox);\r\n\r\n colorShader.unbind();\r\n engine.setDepthFunction(depthFunction);\r\n engine.setDepthWrite(depthWrite);\r\n }\r\n\r\n /**\r\n * Creates buffer for instanced rendering\r\n * @param buffer buffer to set\r\n */\r\n private _createInstanceBuffer(buffer: Float32Array): void {\r\n const vertexBuffers = this._vertexBuffers;\r\n this._cleanupInstanceBuffer();\r\n const matrixBuffer = new Buffer(this.scene.getEngine(), buffer, true, 16, false, true);\r\n\r\n vertexBuffers.world0 = matrixBuffer.createVertexBuffer(\"world0\", 0, 4);\r\n vertexBuffers.world1 = matrixBuffer.createVertexBuffer(\"world1\", 4, 4);\r\n vertexBuffers.world2 = matrixBuffer.createVertexBuffer(\"world2\", 8, 4);\r\n vertexBuffers.world3 = matrixBuffer.createVertexBuffer(\"world3\", 12, 4);\r\n\r\n this._matrixBuffer = matrixBuffer;\r\n }\r\n\r\n /**\r\n * Clean up buffers for instanced rendering\r\n */\r\n private _cleanupInstanceBuffer(): void {\r\n const vertexBuffers = this._vertexBuffers;\r\n if (vertexBuffers.world0) {\r\n vertexBuffers.world0.dispose();\r\n delete vertexBuffers.world0;\r\n }\r\n if (vertexBuffers.world1) {\r\n vertexBuffers.world1.dispose();\r\n delete vertexBuffers.world1;\r\n }\r\n if (vertexBuffers.world2) {\r\n vertexBuffers.world2.dispose();\r\n delete vertexBuffers.world2;\r\n }\r\n if (vertexBuffers.world3) {\r\n vertexBuffers.world3.dispose();\r\n delete vertexBuffers.world3;\r\n }\r\n this._matrices = null;\r\n if (this._matrixBuffer) {\r\n this._matrixBuffer.dispose();\r\n this._matrixBuffer = null;\r\n }\r\n }\r\n\r\n /**\r\n * Clean up resources for instanced rendering\r\n */\r\n private _cleanupInstances(): void {\r\n this._cleanupInstanceBuffer();\r\n if (this._drawWrapperFront) {\r\n this._drawWrapperFront.dispose();\r\n this._drawWrapperFront = null;\r\n }\r\n if (this._drawWrapperBack) {\r\n this._drawWrapperBack.dispose();\r\n this._drawWrapperBack = null;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the resources attached to this renderer.\r\n */\r\n public dispose(): void {\r\n if (this._renderPassIdForOcclusionQuery !== undefined) {\r\n this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery);\r\n this._renderPassIdForOcclusionQuery = undefined as any;\r\n }\r\n\r\n if (!this._colorShader) {\r\n return;\r\n }\r\n\r\n this.onBeforeBoxRenderingObservable.clear();\r\n this.onAfterBoxRenderingObservable.clear();\r\n this.onResourcesReadyObservable.clear();\r\n\r\n this.renderList.dispose();\r\n\r\n this._colorShader.dispose();\r\n this._colorShaderForOcclusionQuery.dispose();\r\n\r\n this._uniformBufferFront.dispose();\r\n this._uniformBufferBack.dispose();\r\n\r\n const buffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n this.scene.getEngine()._releaseBuffer(this._indexBuffer);\r\n\r\n if (this._fillIndexBuffer) {\r\n this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer);\r\n this._fillIndexBuffer = null;\r\n }\r\n this._cleanupInstances();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"boundingBoxRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/boundingBoxRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAwBxC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,wBAAwB,EAAE;IAC7D,GAAG,EAAE;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VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { ISceneComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { BoundingBox } from \"../Culling/boundingBox\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport { CreateBoxVertexData } from \"../Meshes/Builders/boxBuilder\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { _RetryWithInterval } from \"../Misc/timingTools\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\ndeclare module \"../scene\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Scene {\r\n /** @internal (Backing field) */\r\n _boundingBoxRenderer: BoundingBoxRenderer;\r\n\r\n /** @internal (Backing field) */\r\n _forceShowBoundingBoxes: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if all bounding boxes must be rendered\r\n */\r\n forceShowBoundingBoxes: boolean;\r\n\r\n /**\r\n * Gets the bounding box renderer associated with the scene\r\n * @returns a BoundingBoxRenderer\r\n */\r\n getBoundingBoxRenderer(): BoundingBoxRenderer;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"forceShowBoundingBoxes\", {\r\n get: function (this: Scene) {\r\n return this._forceShowBoundingBoxes || false;\r\n },\r\n set: function (this: Scene, value: boolean) {\r\n this._forceShowBoundingBoxes = value;\r\n // Lazyly creates a BB renderer if needed.\r\n if (value) {\r\n this.getBoundingBoxRenderer();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.getBoundingBoxRenderer = function (): BoundingBoxRenderer {\r\n if (!this._boundingBoxRenderer) {\r\n this._boundingBoxRenderer = new BoundingBoxRenderer(this);\r\n }\r\n\r\n return this._boundingBoxRenderer;\r\n};\r\n\r\ndeclare module \"../Meshes/abstractMesh\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractMesh {\r\n /** @internal (Backing field) */\r\n _showBoundingBox: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)\r\n */\r\n showBoundingBox: boolean;\r\n }\r\n}\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"showBoundingBox\", {\r\n get: function (this: AbstractMesh) {\r\n return this._showBoundingBox || false;\r\n },\r\n set: function (this: AbstractMesh, value: boolean) {\r\n this._showBoundingBox = value;\r\n // Lazyly creates a BB renderer if needed.\r\n if (value) {\r\n this.getScene().getBoundingBoxRenderer();\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nconst TempMatrix = Matrix.Identity();\r\nconst TempMatrix2 = new Matrix();\r\nconst TempVec1 = new Vector3();\r\nconst TempVec2 = new Vector3();\r\n// `Matrix.asArray` returns its internal array, so it can be directly updated\r\nconst TempMatrixArray = TempMatrix.asArray();\r\n\r\n// BoundingBox copies from it, so it's safe to reuse vectors here\r\nconst DummyBoundingBox = new BoundingBox(TempVec1, TempVec1);\r\n\r\n/**\r\n * Component responsible of rendering the bounding box of the meshes in a scene.\r\n * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties\r\n */\r\nexport class BoundingBoxRenderer implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_BOUNDINGBOXRENDERER;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Color of the bounding box lines placed in front of an object\r\n */\r\n public frontColor = new Color3(1, 1, 1);\r\n /**\r\n * Color of the bounding box lines placed behind an object\r\n */\r\n public backColor = new Color3(0.1, 0.1, 0.1);\r\n /**\r\n * Defines if the renderer should show the back lines or not\r\n */\r\n public showBackLines = true;\r\n\r\n /**\r\n * Observable raised before rendering a bounding box\r\n * When {@link BoundingBoxRenderer.useInstances} enabled,\r\n * this would only be triggered once for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n */\r\n public onBeforeBoxRenderingObservable = new Observable<BoundingBox>();\r\n\r\n /**\r\n * Observable raised after rendering a bounding box\r\n * When {@link BoundingBoxRenderer.useInstances} enabled,\r\n * this would only be triggered once for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n */\r\n public onAfterBoxRenderingObservable = new Observable<BoundingBox>();\r\n\r\n /**\r\n * Observable raised after resources are created\r\n */\r\n public onResourcesReadyObservable = new Observable<BoundingBoxRenderer>();\r\n\r\n /**\r\n * When false, no bounding boxes will be rendered\r\n */\r\n public enabled = true;\r\n\r\n /** Shader language used by the renderer */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language used in this renderer.\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public renderList = new SmartArray<BoundingBox>(32);\r\n\r\n private _colorShader: ShaderMaterial;\r\n private _colorShaderForOcclusionQuery: ShaderMaterial;\r\n private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n private _indexBuffer: DataBuffer;\r\n private _fillIndexBuffer: Nullable<DataBuffer> = null;\r\n private _fillIndexData: Nullable<IndicesArray> = null;\r\n private _uniformBufferFront: UniformBuffer;\r\n private _uniformBufferBack: UniformBuffer;\r\n private _renderPassIdForOcclusionQuery: number;\r\n /**\r\n * Internal buffer for instanced rendering\r\n */\r\n private _matrixBuffer: Nullable<Buffer> = null;\r\n private _matrices: Nullable<Float32Array> = null;\r\n\r\n /**\r\n * Internal state of whether instanced rendering enabled\r\n */\r\n protected _useInstances = false;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Instantiates a new bounding box renderer in a scene.\r\n * @param scene the scene the renderer renders in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n\r\n const engine = this.scene.getEngine();\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n scene._addComponent(this);\r\n this._uniformBufferFront = new UniformBuffer(this.scene.getEngine(), undefined, undefined, \"BoundingBoxRendererFront\", true);\r\n this._buildUniformLayout(this._uniformBufferFront);\r\n this._uniformBufferBack = new UniformBuffer(this.scene.getEngine(), undefined, undefined, \"BoundingBoxRendererBack\", true);\r\n this._buildUniformLayout(this._uniformBufferBack);\r\n }\r\n\r\n private _buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"color\", 4);\r\n ubo.addUniform(\"world\", 16);\r\n ubo.addUniform(\"viewProjection\", 16);\r\n ubo.addUniform(\"viewProjectionR\", 16);\r\n ubo.create();\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._beforeEvaluateActiveMeshStage.registerStep(SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);\r\n\r\n this.scene._preActiveMeshStage.registerStep(SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh);\r\n\r\n this.scene._evaluateSubMeshStage.registerStep(SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);\r\n\r\n this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);\r\n }\r\n\r\n /**\r\n * Checks if the renderer is ready asynchronously.\r\n * @param timeStep Time step in ms between retries (default is 16)\r\n * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 30000)\r\n * @returns The promise that resolves when the renderer is ready\r\n */\r\n public async whenReadyAsync(timeStep = 16, maxTimeout = 30000): Promise<void> {\r\n this._prepareResources();\r\n return await new Promise((resolve) => {\r\n _RetryWithInterval(\r\n () => {\r\n return this._colorShader.isReady();\r\n },\r\n () => {\r\n resolve();\r\n },\r\n (err, isTimeout) => {\r\n if (!isTimeout) {\r\n Logger.Error(\"BoundingBoxRenderer: An unexpected error occurred while waiting for the renderer to be ready.\");\r\n if (err) {\r\n Logger.Error(err);\r\n if (err.stack) {\r\n Logger.Error(err.stack);\r\n }\r\n }\r\n } else {\r\n Logger.Error(`BoundingBoxRenderer: Timeout while waiting for the renderer to be ready.`);\r\n if (err) {\r\n Logger.Error(err);\r\n }\r\n }\r\n },\r\n timeStep,\r\n maxTimeout\r\n );\r\n });\r\n }\r\n\r\n /** @internal */\r\n public _evaluateSubMesh(mesh: AbstractMesh, subMesh: SubMesh): void {\r\n if (mesh.showSubMeshesBoundingBox) {\r\n const boundingInfo = subMesh.getBoundingInfo();\r\n if (boundingInfo !== null && boundingInfo !== undefined) {\r\n boundingInfo.boundingBox._tag = mesh.renderingGroupId;\r\n this.renderList.push(boundingInfo.boundingBox);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _preActiveMesh(mesh: AbstractMesh): void {\r\n if (mesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {\r\n const boundingInfo = mesh.getBoundingInfo();\r\n boundingInfo.boundingBox._tag = mesh.renderingGroupId;\r\n this.renderList.push(boundingInfo.boundingBox);\r\n }\r\n }\r\n\r\n private _prepareResources(): void {\r\n if (this._colorShader) {\r\n return;\r\n }\r\n\r\n this._colorShader = new ShaderMaterial(\r\n \"colorShader\",\r\n this.scene,\r\n \"boundingBoxRenderer\",\r\n {\r\n attributes: [VertexBuffer.PositionKind, \"world0\", \"world1\", \"world2\", \"world3\"],\r\n\r\n uniforms: [\"world\", \"viewProjection\", \"viewProjectionR\", \"color\"],\r\n uniformBuffers: [\"BoundingBoxRenderer\"],\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/boundingBoxRenderer.vertex\"), import(\"../ShadersWGSL/boundingBoxRenderer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/boundingBoxRenderer.vertex\"), import(\"../Shaders/boundingBoxRenderer.fragment\")]);\r\n }\r\n },\r\n },\r\n false\r\n );\r\n this._colorShader.setDefine(\"INSTANCES\", this._useInstances);\r\n this._colorShader.doNotSerialize = true;\r\n\r\n this._colorShader.reservedDataStore = {\r\n hidden: true,\r\n };\r\n\r\n this._colorShaderForOcclusionQuery = new ShaderMaterial(\r\n \"colorShaderOccQuery\",\r\n this.scene,\r\n \"boundingBoxRenderer\",\r\n {\r\n attributes: [VertexBuffer.PositionKind],\r\n uniforms: [\"world\", \"viewProjection\", \"viewProjectionR\", \"color\"],\r\n uniformBuffers: [\"BoundingBoxRenderer\"],\r\n shaderLanguage: this._shaderLanguage,\r\n extraInitializationsAsync: async () => {\r\n if (this._shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([import(\"../ShadersWGSL/boundingBoxRenderer.vertex\"), import(\"../ShadersWGSL/boundingBoxRenderer.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/boundingBoxRenderer.vertex\"), import(\"../Shaders/boundingBoxRenderer.fragment\")]);\r\n }\r\n },\r\n },\r\n true\r\n );\r\n this._colorShaderForOcclusionQuery.doNotSerialize = true;\r\n\r\n this._colorShaderForOcclusionQuery.reservedDataStore = {\r\n hidden: true,\r\n };\r\n\r\n const engine = this.scene.getEngine();\r\n const boxdata = CreateBoxVertexData({ size: 1.0 });\r\n this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, <FloatArray>boxdata.positions, VertexBuffer.PositionKind, false);\r\n this._createIndexBuffer();\r\n this._fillIndexData = boxdata.indices;\r\n this.onResourcesReadyObservable.notifyObservers(this);\r\n }\r\n\r\n private _createIndexBuffer(): void {\r\n const engine = this.scene.getEngine();\r\n this._indexBuffer = engine.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n const vb = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vb) {\r\n vb._rebuild();\r\n }\r\n this._createIndexBuffer();\r\n\r\n if (this._matrixBuffer) {\r\n this._matrixBuffer._rebuild();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public reset(): void {\r\n this.renderList.reset();\r\n }\r\n\r\n /**\r\n * Render the bounding boxes of a specific rendering group\r\n * @param renderingGroupId defines the rendering group to render\r\n */\r\n public render(renderingGroupId: number): void {\r\n if (this.renderList.length === 0 || !this.enabled) {\r\n return;\r\n }\r\n\r\n if (this._useInstances) {\r\n this._renderInstanced(renderingGroupId);\r\n return;\r\n }\r\n\r\n this._prepareResources();\r\n\r\n if (!this._colorShader.isReady()) {\r\n return;\r\n }\r\n\r\n const engine = this.scene.getEngine();\r\n engine.setDepthWrite(false);\r\n\r\n const transformMatrix = this.scene.getTransformMatrix();\r\n\r\n for (let boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {\r\n const boundingBox = this.renderList.data[boundingBoxIndex];\r\n if (boundingBox._tag !== renderingGroupId) {\r\n continue;\r\n }\r\n\r\n this._createWrappersForBoundingBox(boundingBox);\r\n this.onBeforeBoxRenderingObservable.notifyObservers(boundingBox);\r\n\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n const diff = max.subtract(min);\r\n const median = min.add(diff.scale(0.5));\r\n\r\n const worldMatrix = Matrix.Scaling(diff.x, diff.y, diff.z)\r\n .multiply(Matrix.Translation(median.x, median.y, median.z))\r\n .multiply(boundingBox.getWorldMatrix());\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n\r\n if (this.showBackLines) {\r\n const drawWrapperBack = boundingBox._drawWrapperBack ?? this._colorShader._getDrawWrapper();\r\n\r\n this._colorShader._preBind(drawWrapperBack);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());\r\n\r\n // Back\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToLessOrEqual();\r\n } else {\r\n engine.setDepthFunctionToGreaterOrEqual();\r\n }\r\n this._uniformBufferBack.bindToEffect(drawWrapperBack.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferBack.updateColor4(\"color\", this.backColor, 1);\r\n this._uniformBufferBack.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferBack.updateMatrix(\"viewProjection\", transformMatrix);\r\n this._uniformBufferBack.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24);\r\n }\r\n\r\n const drawWrapperFront = boundingBox._drawWrapperFront ?? this._colorShader._getDrawWrapper();\r\n\r\n this._colorShader._preBind(drawWrapperFront);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());\r\n\r\n // Front\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n this._uniformBufferFront.bindToEffect(drawWrapperFront.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferFront.updateColor4(\"color\", this.frontColor, 1);\r\n this._uniformBufferFront.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferFront.updateMatrix(\"viewProjection\", transformMatrix);\r\n this._uniformBufferFront.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24);\r\n\r\n this.onAfterBoxRenderingObservable.notifyObservers(boundingBox);\r\n }\r\n this._colorShader.unbind();\r\n engine.setDepthFunctionToLessOrEqual();\r\n engine.setDepthWrite(true);\r\n }\r\n\r\n private _createWrappersForBoundingBox(boundingBox: BoundingBox | BoundingBoxRenderer): void {\r\n if (!boundingBox._drawWrapperFront) {\r\n const engine = this.scene.getEngine();\r\n\r\n boundingBox._drawWrapperFront = new DrawWrapper(engine);\r\n boundingBox._drawWrapperBack = new DrawWrapper(engine);\r\n\r\n boundingBox._drawWrapperFront.setEffect(this._colorShader.getEffect());\r\n boundingBox._drawWrapperBack.setEffect(this._colorShader.getEffect());\r\n }\r\n }\r\n\r\n /**\r\n * In case of occlusion queries, we can render the occlusion bounding box through this method\r\n * @param mesh Define the mesh to render the occlusion bounding box for\r\n */\r\n public renderOcclusionBoundingBox(mesh: AbstractMesh): void {\r\n const engine = this.scene.getEngine();\r\n\r\n if (this._renderPassIdForOcclusionQuery === undefined) {\r\n this._renderPassIdForOcclusionQuery = engine.createRenderPassId(`Render pass for occlusion query`);\r\n }\r\n\r\n const currentRenderPassId = engine.currentRenderPassId;\r\n\r\n engine.currentRenderPassId = this._renderPassIdForOcclusionQuery;\r\n\r\n this._prepareResources();\r\n\r\n const subMesh = mesh.subMeshes[0];\r\n\r\n if (!this._colorShaderForOcclusionQuery.isReady(mesh, undefined, subMesh) || !mesh.hasBoundingInfo) {\r\n engine.currentRenderPassId = currentRenderPassId;\r\n return;\r\n }\r\n\r\n if (!this._fillIndexBuffer) {\r\n this._fillIndexBuffer = engine.createIndexBuffer(this._fillIndexData!);\r\n }\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n\r\n engine.setDepthWrite(false);\r\n engine.setColorWrite(false);\r\n\r\n const boundingBox = mesh.getBoundingInfo().boundingBox;\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n const diff = max.subtract(min);\r\n const median = min.add(diff.scale(0.5));\r\n\r\n const worldMatrix = Matrix.Scaling(diff.x, diff.y, diff.z)\r\n .multiply(Matrix.Translation(median.x, median.y, median.z))\r\n .multiply(boundingBox.getWorldMatrix());\r\n\r\n const drawWrapper = subMesh._drawWrapper;\r\n\r\n this._colorShaderForOcclusionQuery._preBind(drawWrapper);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, <Effect>drawWrapper.effect);\r\n\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n\r\n this.scene.resetCachedMaterial();\r\n\r\n this._uniformBufferFront.bindToEffect(drawWrapper.effect!, \"BoundingBoxRenderer\");\r\n this._uniformBufferFront.updateMatrix(\"world\", worldMatrix);\r\n this._uniformBufferFront.updateMatrix(\"viewProjection\", this.scene.getTransformMatrix());\r\n this._uniformBufferFront.update();\r\n\r\n engine.drawElementsType(Material.TriangleFillMode, 0, 36);\r\n\r\n this._colorShaderForOcclusionQuery.unbind();\r\n engine.setDepthFunctionToLessOrEqual();\r\n engine.setDepthWrite(true);\r\n engine.setColorWrite(true);\r\n\r\n engine.currentRenderPassId = currentRenderPassId;\r\n }\r\n\r\n /**\r\n * Sets whether to use instanced rendering.\r\n * When not enabled, BoundingBoxRenderer renders in a loop,\r\n * calling engine.drawElementsType for each bounding box in renderList,\r\n * making every bounding box 1 or 2 draw call.\r\n * When enabled, it collects bounding boxes to render,\r\n * and render all boxes in 1 or 2 draw call.\r\n * This could make the rendering with many bounding boxes much faster than not enabled,\r\n * but could result in a difference in rendering result if\r\n * {@link BoundingBoxRenderer.showBackLines} enabled,\r\n * because drawing the black/white part of each box one after the other\r\n * can be different from drawing the black part of all boxes and then the white part.\r\n * Also, when enabled, events of {@link BoundingBoxRenderer.onBeforeBoxRenderingObservable}\r\n * and {@link BoundingBoxRenderer.onAfterBoxRenderingObservable} would only be triggered once\r\n * for one rendering, instead of once every bounding box.\r\n * Events would be triggered with a dummy box to keep backwards compatibility,\r\n * the passed bounding box has no meaning and should be ignored.\r\n * @param val whether to use instanced rendering\r\n */\r\n public set useInstances(val: boolean) {\r\n this._useInstances = val;\r\n if (this._colorShader) {\r\n this._colorShader.setDefine(\"INSTANCES\", val);\r\n }\r\n if (!val) {\r\n this._cleanupInstances();\r\n }\r\n }\r\n\r\n public get useInstances(): boolean {\r\n return this._useInstances;\r\n }\r\n\r\n /**\r\n * Instanced render the bounding boxes of a specific rendering group\r\n * @param renderingGroupId defines the rendering group to render\r\n */\r\n private _renderInstanced(renderingGroupId: number): void {\r\n if (this.renderList.length === 0 || !this.enabled) {\r\n return;\r\n }\r\n this._prepareResources();\r\n\r\n if (!this._colorShader.isReady()) {\r\n return;\r\n }\r\n\r\n const colorShader = this._colorShader;\r\n let matrices = this._matrices;\r\n const expectedLength = this.renderList.length * 16;\r\n if (!matrices || matrices.length < expectedLength || matrices.length > expectedLength * 2) {\r\n matrices = new Float32Array(expectedLength);\r\n this._matrices = matrices;\r\n }\r\n\r\n this.onBeforeBoxRenderingObservable.notifyObservers(DummyBoundingBox);\r\n\r\n let instancesCount = 0;\r\n const floatingOriginOffset = this.scene.floatingOriginOffset;\r\n\r\n for (let boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {\r\n const boundingBox = this.renderList.data[boundingBoxIndex];\r\n if (boundingBox._tag !== renderingGroupId) {\r\n continue;\r\n }\r\n\r\n const min = boundingBox.minimum;\r\n const max = boundingBox.maximum;\r\n\r\n const diff = max.subtractToRef(min, TempVec2);\r\n const median = min.addToRef(diff.scaleToRef(0.5, TempVec1), TempVec1);\r\n\r\n const m = TempMatrixArray;\r\n\r\n // Directly update the matrix values in column-major order\r\n m[0] = diff._x; // Scale X\r\n m[3] = median._x; // Translate X\r\n\r\n m[5] = diff._y; // Scale Y\r\n m[7] = median._y; // Translate Y\r\n\r\n m[10] = diff._z; // Scale Z\r\n m[11] = median._z; // Translate Z\r\n\r\n const offset = instancesCount * 16;\r\n // Multiply into Float64 temp matrix, subtract offset in Float64, then copy to Float32 buffer\r\n // to preserve precision at large coordinates.\r\n const resultM = TempMatrix2.asArray();\r\n TempMatrix.multiplyToArray(boundingBox.getWorldMatrix(), resultM, 0);\r\n resultM[12] -= floatingOriginOffset.x;\r\n resultM[13] -= floatingOriginOffset.y;\r\n resultM[14] -= floatingOriginOffset.z;\r\n TempMatrix2.copyToArray(matrices, offset);\r\n instancesCount++;\r\n }\r\n\r\n const engine = this.scene.getEngine();\r\n // keeps the original depth function and depth write\r\n const depthFunction = engine.getDepthFunction() ?? Constants.LEQUAL;\r\n const depthWrite = engine.getDepthWrite();\r\n engine.setDepthWrite(false);\r\n const matrixBuffer = this._matrixBuffer;\r\n if (matrixBuffer?.isUpdatable() && matrixBuffer.getData() === matrices) {\r\n matrixBuffer.update(matrices);\r\n } else {\r\n this._createInstanceBuffer(matrices);\r\n }\r\n\r\n this._createWrappersForBoundingBox(this);\r\n\r\n const useReverseDepthBuffer = engine.useReverseDepthBuffer;\r\n const transformMatrix = this.scene.getTransformMatrix();\r\n\r\n if (this.showBackLines) {\r\n const drawWrapperBack = this._drawWrapperBack ?? colorShader._getDrawWrapper();\r\n\r\n colorShader._preBind(drawWrapperBack);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, colorShader.getEffect());\r\n\r\n // Back\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToLessOrEqual();\r\n } else {\r\n engine.setDepthFunctionToGreaterOrEqual();\r\n }\r\n const _uniformBufferBack: UniformBuffer = this._uniformBufferBack;\r\n\r\n _uniformBufferBack.bindToEffect(drawWrapperBack.effect!, \"BoundingBoxRenderer\");\r\n _uniformBufferBack.updateColor4(\"color\", this.backColor, 1);\r\n _uniformBufferBack.updateMatrix(\"viewProjection\", transformMatrix);\r\n _uniformBufferBack.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24, instancesCount);\r\n }\r\n\r\n const drawWrapperFront = colorShader._getDrawWrapper();\r\n\r\n colorShader._preBind(drawWrapperFront);\r\n\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, colorShader.getEffect());\r\n\r\n // Front\r\n if (useReverseDepthBuffer) {\r\n engine.setDepthFunctionToGreater();\r\n } else {\r\n engine.setDepthFunctionToLess();\r\n }\r\n const _uniformBufferFront: UniformBuffer = this._uniformBufferFront;\r\n _uniformBufferFront.bindToEffect(drawWrapperFront.effect!, \"BoundingBoxRenderer\");\r\n _uniformBufferFront.updateColor4(\"color\", this.frontColor, 1);\r\n _uniformBufferFront.updateMatrix(\"viewProjection\", transformMatrix);\r\n _uniformBufferFront.update();\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.LineListDrawMode, 0, 24, instancesCount);\r\n\r\n this.onAfterBoxRenderingObservable.notifyObservers(DummyBoundingBox);\r\n\r\n colorShader.unbind();\r\n engine.setDepthFunction(depthFunction);\r\n engine.setDepthWrite(depthWrite);\r\n }\r\n\r\n /**\r\n * Creates buffer for instanced rendering\r\n * @param buffer buffer to set\r\n */\r\n private _createInstanceBuffer(buffer: Float32Array): void {\r\n const vertexBuffers = this._vertexBuffers;\r\n this._cleanupInstanceBuffer();\r\n const matrixBuffer = new Buffer(this.scene.getEngine(), buffer, true, 16, false, true);\r\n\r\n vertexBuffers.world0 = matrixBuffer.createVertexBuffer(\"world0\", 0, 4);\r\n vertexBuffers.world1 = matrixBuffer.createVertexBuffer(\"world1\", 4, 4);\r\n vertexBuffers.world2 = matrixBuffer.createVertexBuffer(\"world2\", 8, 4);\r\n vertexBuffers.world3 = matrixBuffer.createVertexBuffer(\"world3\", 12, 4);\r\n\r\n this._matrixBuffer = matrixBuffer;\r\n }\r\n\r\n /**\r\n * Clean up buffers for instanced rendering\r\n */\r\n private _cleanupInstanceBuffer(): void {\r\n const vertexBuffers = this._vertexBuffers;\r\n if (vertexBuffers.world0) {\r\n vertexBuffers.world0.dispose();\r\n delete vertexBuffers.world0;\r\n }\r\n if (vertexBuffers.world1) {\r\n vertexBuffers.world1.dispose();\r\n delete vertexBuffers.world1;\r\n }\r\n if (vertexBuffers.world2) {\r\n vertexBuffers.world2.dispose();\r\n delete vertexBuffers.world2;\r\n }\r\n if (vertexBuffers.world3) {\r\n vertexBuffers.world3.dispose();\r\n delete vertexBuffers.world3;\r\n }\r\n this._matrices = null;\r\n if (this._matrixBuffer) {\r\n this._matrixBuffer.dispose();\r\n this._matrixBuffer = null;\r\n }\r\n }\r\n\r\n /**\r\n * Clean up resources for instanced rendering\r\n */\r\n private _cleanupInstances(): void {\r\n this._cleanupInstanceBuffer();\r\n if (this._drawWrapperFront) {\r\n this._drawWrapperFront.dispose();\r\n this._drawWrapperFront = null;\r\n }\r\n if (this._drawWrapperBack) {\r\n this._drawWrapperBack.dispose();\r\n this._drawWrapperBack = null;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose and release the resources attached to this renderer.\r\n */\r\n public dispose(): void {\r\n if (this._renderPassIdForOcclusionQuery !== undefined) {\r\n this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery);\r\n this._renderPassIdForOcclusionQuery = undefined as any;\r\n }\r\n\r\n if (!this._colorShader) {\r\n return;\r\n }\r\n\r\n this.onBeforeBoxRenderingObservable.clear();\r\n this.onAfterBoxRenderingObservable.clear();\r\n this.onResourcesReadyObservable.clear();\r\n\r\n this.renderList.dispose();\r\n\r\n this._colorShader.dispose();\r\n this._colorShaderForOcclusionQuery.dispose();\r\n\r\n this._uniformBufferFront.dispose();\r\n this._uniformBufferBack.dispose();\r\n\r\n const buffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._vertexBuffers[VertexBuffer.PositionKind] = null;\r\n }\r\n this.scene.getEngine()._releaseBuffer(this._indexBuffer);\r\n\r\n if (this._fillIndexBuffer) {\r\n this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer);\r\n this._fillIndexBuffer = null;\r\n }\r\n this._cleanupInstances();\r\n }\r\n}\r\n"]}
|
|
@@ -672,10 +672,13 @@ export class EdgesRenderer {
|
|
|
672
672
|
if (!isFrozen) {
|
|
673
673
|
let offset = 0;
|
|
674
674
|
for (let i = 0; i < instanceCount; ++i) {
|
|
675
|
-
this.customInstances.data[i]
|
|
676
|
-
instanceStorage.instancesData
|
|
677
|
-
|
|
678
|
-
|
|
675
|
+
const instanceMatrix = this.customInstances.data[i];
|
|
676
|
+
instanceMatrix.copyToArray(instanceStorage.instancesData, offset);
|
|
677
|
+
// Subtract from Float64 source to preserve precision at large coordinates.
|
|
678
|
+
const instanceM = instanceMatrix.asArray();
|
|
679
|
+
instanceStorage.instancesData[offset + 12] = instanceM[12] - floatingOriginOffset.x;
|
|
680
|
+
instanceStorage.instancesData[offset + 13] = instanceM[13] - floatingOriginOffset.y;
|
|
681
|
+
instanceStorage.instancesData[offset + 14] = instanceM[14] - floatingOriginOffset.z;
|
|
679
682
|
offset += 16;
|
|
680
683
|
}
|
|
681
684
|
instanceStorage.instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instanceCount);
|