@babylonjs/core 6.41.2 → 6.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/arcRotateCamera.js +7 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Culling/ray.d.ts +2 -2
- package/Culling/ray.js +3 -2
- package/Culling/ray.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Maths/halton2DSequence.d.ts +47 -0
- package/Maths/halton2DSequence.js +80 -0
- package/Maths/halton2DSequence.js.map +1 -0
- package/Maths/index.d.ts +1 -0
- package/Maths/index.js +1 -0
- package/Maths/index.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/mesh.js +10 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/trailMesh.js +24 -19
- package/Meshes/trailMesh.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +0 -1
- package/Physics/v2/Plugins/havokPlugin.js +3 -2
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +1 -0
- package/Physics/v2/physicsEngine.js +1 -0
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.d.ts +111 -0
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +303 -0
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -0
- package/Shaders/taa.fragment.d.ts +5 -0
- package/Shaders/taa.fragment.js +10 -0
- package/Shaders/taa.fragment.js.map +1 -0
- package/package.json +1 -1
package/Meshes/trailMesh.js
CHANGED
|
@@ -29,7 +29,7 @@ export class TrailMesh extends Mesh {
|
|
|
29
29
|
this._length = length;
|
|
30
30
|
this._sectionVectors = [];
|
|
31
31
|
this._sectionNormalVectors = [];
|
|
32
|
-
for (let i = 0; i
|
|
32
|
+
for (let i = 0; i <= this._sectionPolygonPointsCount; i++) {
|
|
33
33
|
this._sectionVectors[i] = Vector3.Zero();
|
|
34
34
|
this._sectionNormalVectors[i] = Vector3.Zero();
|
|
35
35
|
}
|
|
@@ -47,6 +47,7 @@ export class TrailMesh extends Mesh {
|
|
|
47
47
|
const positions = [];
|
|
48
48
|
const normals = [];
|
|
49
49
|
const indices = [];
|
|
50
|
+
const uvs = [];
|
|
50
51
|
let meshCenter = Vector3.Zero();
|
|
51
52
|
if (this._generator instanceof AbstractMesh && this._generator.hasBoundingInfo) {
|
|
52
53
|
meshCenter = this._generator.getBoundingInfo().boundingBox.centerWorld;
|
|
@@ -55,25 +56,28 @@ export class TrailMesh extends Mesh {
|
|
|
55
56
|
meshCenter = this._generator.position;
|
|
56
57
|
}
|
|
57
58
|
const alpha = (2 * Math.PI) / this._sectionPolygonPointsCount;
|
|
58
|
-
for (let i = 0; i
|
|
59
|
-
|
|
59
|
+
for (let i = 0; i <= this._sectionPolygonPointsCount; i++) {
|
|
60
|
+
const angle = i !== this._sectionPolygonPointsCount ? i * alpha : 0;
|
|
61
|
+
positions.push(meshCenter.x + Math.cos(angle) * this.diameter, meshCenter.y + Math.sin(angle) * this.diameter, meshCenter.z);
|
|
62
|
+
uvs.push(i / this._sectionPolygonPointsCount, 0);
|
|
60
63
|
}
|
|
61
64
|
for (let i = 1; i <= this._length; i++) {
|
|
62
|
-
for (let j = 0; j
|
|
63
|
-
|
|
65
|
+
for (let j = 0; j <= this._sectionPolygonPointsCount; j++) {
|
|
66
|
+
const angle = j !== this._sectionPolygonPointsCount ? j * alpha : 0;
|
|
67
|
+
positions.push(meshCenter.x + Math.cos(angle) * this.diameter, meshCenter.y + Math.sin(angle) * this.diameter, meshCenter.z);
|
|
68
|
+
uvs.push(j / this._sectionPolygonPointsCount, i / this._length);
|
|
64
69
|
}
|
|
65
|
-
const l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
|
|
66
|
-
for (let j = 0; j
|
|
70
|
+
const l = positions.length / 3 - 2 * (this._sectionPolygonPointsCount + 1);
|
|
71
|
+
for (let j = 0; j <= this._sectionPolygonPointsCount; j++) {
|
|
67
72
|
indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
|
|
68
73
|
indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
|
|
69
74
|
}
|
|
70
|
-
indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
|
|
71
|
-
indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
|
|
72
75
|
}
|
|
73
76
|
VertexData.ComputeNormals(positions, indices, normals);
|
|
74
77
|
data.positions = positions;
|
|
75
78
|
data.normals = normals;
|
|
76
79
|
data.indices = indices;
|
|
80
|
+
data.uvs = uvs;
|
|
77
81
|
data.applyToMesh(this, true);
|
|
78
82
|
if (this._autoStart) {
|
|
79
83
|
this.start();
|
|
@@ -107,21 +111,22 @@ export class TrailMesh extends Mesh {
|
|
|
107
111
|
const normals = this.getVerticesData(VertexBuffer.NormalKind);
|
|
108
112
|
const wm = this._generator.getWorldMatrix();
|
|
109
113
|
if (positions && normals) {
|
|
110
|
-
for (let i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
|
|
111
|
-
positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - (normals[i] / this._length) * this.diameter;
|
|
114
|
+
for (let i = 3 * (this._sectionPolygonPointsCount + 1); i < positions.length; i++) {
|
|
115
|
+
positions[i - 3 * (this._sectionPolygonPointsCount + 1)] = positions[i] - (normals[i] / this._length) * this.diameter;
|
|
112
116
|
}
|
|
113
|
-
for (let i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
|
|
114
|
-
normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
|
|
117
|
+
for (let i = 3 * (this._sectionPolygonPointsCount + 1); i < normals.length; i++) {
|
|
118
|
+
normals[i - 3 * (this._sectionPolygonPointsCount + 1)] = normals[i];
|
|
115
119
|
}
|
|
116
|
-
const l = positions.length - 3 * this._sectionPolygonPointsCount;
|
|
120
|
+
const l = positions.length - 3 * (this._sectionPolygonPointsCount + 1);
|
|
117
121
|
const alpha = (2 * Math.PI) / this._sectionPolygonPointsCount;
|
|
118
|
-
for (let i = 0; i
|
|
119
|
-
|
|
120
|
-
this.
|
|
122
|
+
for (let i = 0; i <= this._sectionPolygonPointsCount; i++) {
|
|
123
|
+
const angle = i !== this._sectionPolygonPointsCount ? i * alpha : 0;
|
|
124
|
+
this._sectionVectors[i].copyFromFloats(Math.cos(angle) * this.diameter, Math.sin(angle) * this.diameter, 0);
|
|
125
|
+
this._sectionNormalVectors[i].copyFromFloats(Math.cos(angle), Math.sin(angle), 0);
|
|
121
126
|
Vector3.TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
|
|
122
127
|
Vector3.TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
|
|
123
128
|
}
|
|
124
|
-
for (let i = 0; i
|
|
129
|
+
for (let i = 0; i <= this._sectionPolygonPointsCount; i++) {
|
|
125
130
|
positions[l + 3 * i] = this._sectionVectors[i].x;
|
|
126
131
|
positions[l + 3 * i + 1] = this._sectionVectors[i].y;
|
|
127
132
|
positions[l + 3 * i + 2] = this._sectionVectors[i].z;
|
|
@@ -140,7 +145,7 @@ export class TrailMesh extends Mesh {
|
|
|
140
145
|
* @returns a new mesh
|
|
141
146
|
*/
|
|
142
147
|
clone(name = "", newGenerator) {
|
|
143
|
-
return new TrailMesh(name, newGenerator
|
|
148
|
+
return new TrailMesh(name, newGenerator ?? this._generator, this.getScene(), this.diameter, this._length, this._autoStart);
|
|
144
149
|
}
|
|
145
150
|
/**
|
|
146
151
|
* Serializes this trail mesh
|
package/Meshes/trailMesh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trailMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/trailMesh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,IAAI,CAAC,gBAAgB,GAAG,CAAC,UAAe,EAAE,KAAY,EAAE,EAAE;IACtD,OAAO,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,IAAI;IAe/B;;;;;;;;OAQG;IACH,YAAY,IAAY,EAAE,SAAwB,EAAE,KAAa,EAAE,WAAmB,CAAC,EAAE,SAAiB,EAAE,EAAE,YAAqB,IAAI;QACnI,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAff,+BAA0B,GAAW,CAAC,CAAC;QAiB3C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;Q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AQ,IAAI,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IACpJ,CAAC;CACJ","sourcesContent":["import { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\n\r\nMesh._TrailMeshParser = (parsedMesh: any, scene: Scene) => {\r\n return TrailMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * Class used to create a trail following a mesh\r\n */\r\nexport class TrailMesh extends Mesh {\r\n /**\r\n * The diameter of the trail, i.e. the width of the ribbon.\r\n */\r\n public diameter: number;\r\n\r\n private _generator: TransformNode;\r\n private _autoStart: boolean;\r\n private _running: boolean;\r\n private _length: number;\r\n private _sectionPolygonPointsCount: number = 4;\r\n private _sectionVectors: Array<Vector3>;\r\n private _sectionNormalVectors: Array<Vector3>;\r\n private _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n\r\n /**\r\n * Creates a new TrailMesh.\r\n * @param name The value used by scene.getMeshByName() to do a lookup.\r\n * @param generator The mesh or transform node to generate a trail.\r\n * @param scene The scene to add this mesh to.\r\n * @param diameter Diameter of trailing mesh. Default is 1.\r\n * @param length Length of trailing mesh. Default is 60.\r\n * @param autoStart Automatically start trailing mesh. Default true.\r\n */\r\n constructor(name: string, generator: TransformNode, scene?: Scene, diameter: number = 1, length: number = 60, autoStart: boolean = true) {\r\n super(name, scene);\r\n\r\n this._running = false;\r\n this._autoStart = autoStart;\r\n this._generator = generator;\r\n this.diameter = diameter;\r\n this._length = length;\r\n this._sectionVectors = [];\r\n this._sectionNormalVectors = [];\r\n for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {\r\n this._sectionVectors[i] = Vector3.Zero();\r\n this._sectionNormalVectors[i] = Vector3.Zero();\r\n }\r\n this._createMesh();\r\n }\r\n\r\n /**\r\n * \"TrailMesh\"\r\n * @returns \"TrailMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"TrailMesh\";\r\n }\r\n\r\n private _createMesh(): void {\r\n const data: VertexData = new VertexData();\r\n const positions: Array<number> = [];\r\n const normals: Array<number> = [];\r\n const indices: Array<number> = [];\r\n let meshCenter = Vector3.Zero();\r\n if (this._generator instanceof AbstractMesh && this._generator.hasBoundingInfo) {\r\n meshCenter = this._generator.getBoundingInfo().boundingBox.centerWorld;\r\n } else {\r\n meshCenter = this._generator.position;\r\n }\r\n const alpha: number = (2 * Math.PI) / this._sectionPolygonPointsCount;\r\n for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {\r\n positions.push(meshCenter.x + Math.cos(i * alpha) * this.diameter, meshCenter.y + Math.sin(i * alpha) * this.diameter, meshCenter.z);\r\n }\r\n for (let i: number = 1; i <= this._length; i++) {\r\n for (let j: number = 0; j < this._sectionPolygonPointsCount; j++) {\r\n positions.push(meshCenter.x + Math.cos(j * alpha) * this.diameter, meshCenter.y + Math.sin(j * alpha) * this.diameter, meshCenter.z);\r\n }\r\n const l: number = positions.length / 3 - 2 * this._sectionPolygonPointsCount;\r\n for (let j: number = 0; j < this._sectionPolygonPointsCount - 1; j++) {\r\n indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);\r\n indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);\r\n }\r\n indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);\r\n indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);\r\n }\r\n VertexData.ComputeNormals(positions, indices, normals);\r\n data.positions = positions;\r\n data.normals = normals;\r\n data.indices = indices;\r\n data.applyToMesh(this, true);\r\n if (this._autoStart) {\r\n this.start();\r\n }\r\n }\r\n\r\n /**\r\n * Start trailing mesh.\r\n */\r\n public start(): void {\r\n if (!this._running) {\r\n this._running = true;\r\n this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(() => {\r\n this.update();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Stop trailing mesh.\r\n */\r\n public stop(): void {\r\n if (this._beforeRenderObserver && this._running) {\r\n this._running = false;\r\n this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Update trailing mesh geometry.\r\n */\r\n public update(): void {\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = this.getVerticesData(VertexBuffer.NormalKind);\r\n const wm = this._generator.getWorldMatrix();\r\n if (positions && normals) {\r\n for (let i: number = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {\r\n positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - (normals[i] / this._length) * this.diameter;\r\n }\r\n for (let i: number = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {\r\n normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];\r\n }\r\n const l: number = positions.length - 3 * this._sectionPolygonPointsCount;\r\n const alpha: number = (2 * Math.PI) / this._sectionPolygonPointsCount;\r\n for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {\r\n this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this.diameter, Math.sin(i * alpha) * this.diameter, 0);\r\n this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);\r\n Vector3.TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);\r\n Vector3.TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);\r\n }\r\n for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {\r\n positions[l + 3 * i] = this._sectionVectors[i].x;\r\n positions[l + 3 * i + 1] = this._sectionVectors[i].y;\r\n positions[l + 3 * i + 2] = this._sectionVectors[i].z;\r\n normals[l + 3 * i] = this._sectionNormalVectors[i].x;\r\n normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;\r\n normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;\r\n }\r\n this.updateVerticesData(VertexBuffer.PositionKind, positions, true, false);\r\n this.updateVerticesData(VertexBuffer.NormalKind, normals, true, false);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a new TrailMesh object.\r\n * @param name is a string, the name given to the new mesh\r\n * @param newGenerator use new generator object for cloned trail mesh\r\n * @returns a new mesh\r\n */\r\n public clone(name: string = \"\", newGenerator: TransformNode): TrailMesh {\r\n return new TrailMesh(name, newGenerator === undefined ? this._generator : newGenerator, this.getScene(), this.diameter, this._length, this._autoStart);\r\n }\r\n\r\n /**\r\n * Serializes this trail mesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n\r\n serializationObject.generatorId = this._generator.id;\r\n }\r\n\r\n /**\r\n * Parses a serialized trail mesh\r\n * @param parsedMesh the serialized mesh\r\n * @param scene the scene to create the trail mesh in\r\n * @returns the created trail mesh\r\n */\r\n public static Parse(parsedMesh: any, scene: Scene): TrailMesh {\r\n const generator = scene.getLastMeshById(parsedMesh.generatorId) ?? scene.getLastTransformNodeById(parsedMesh.generatorId);\r\n\r\n if (!generator) {\r\n throw new Error(\"TrailMesh: generator not found with ID \" + parsedMesh.generatorId);\r\n }\r\n\r\n return new TrailMesh(parsedMesh.name, generator, scene, parsedMesh.diameter ?? parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"trailMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/trailMesh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,E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AU,CAAC,CAAC;IACpJ,CAAC;CACJ","sourcesContent":["import { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\n\r\nMesh._TrailMeshParser = (parsedMesh: any, scene: Scene) => {\r\n return TrailMesh.Parse(parsedMesh, scene);\r\n};\r\n\r\n/**\r\n * Class used to create a trail following a mesh\r\n */\r\nexport class TrailMesh extends Mesh {\r\n /**\r\n * The diameter of the trail, i.e. the width of the ribbon.\r\n */\r\n public diameter: number;\r\n\r\n private _generator: TransformNode;\r\n private _autoStart: boolean;\r\n private _running: boolean;\r\n private _length: number;\r\n private _sectionPolygonPointsCount: number = 4;\r\n private _sectionVectors: Array<Vector3>;\r\n private _sectionNormalVectors: Array<Vector3>;\r\n private _beforeRenderObserver: Nullable<Observer<Scene>>;\r\n\r\n /**\r\n * Creates a new TrailMesh.\r\n * @param name The value used by scene.getMeshByName() to do a lookup.\r\n * @param generator The mesh or transform node to generate a trail.\r\n * @param scene The scene to add this mesh to.\r\n * @param diameter Diameter of trailing mesh. Default is 1.\r\n * @param length Length of trailing mesh. Default is 60.\r\n * @param autoStart Automatically start trailing mesh. Default true.\r\n */\r\n constructor(name: string, generator: TransformNode, scene?: Scene, diameter: number = 1, length: number = 60, autoStart: boolean = true) {\r\n super(name, scene);\r\n\r\n this._running = false;\r\n this._autoStart = autoStart;\r\n this._generator = generator;\r\n this.diameter = diameter;\r\n this._length = length;\r\n this._sectionVectors = [];\r\n this._sectionNormalVectors = [];\r\n for (let i: number = 0; i <= this._sectionPolygonPointsCount; i++) {\r\n this._sectionVectors[i] = Vector3.Zero();\r\n this._sectionNormalVectors[i] = Vector3.Zero();\r\n }\r\n this._createMesh();\r\n }\r\n\r\n /**\r\n * \"TrailMesh\"\r\n * @returns \"TrailMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"TrailMesh\";\r\n }\r\n\r\n private _createMesh(): void {\r\n const data: VertexData = new VertexData();\r\n const positions: Array<number> = [];\r\n const normals: Array<number> = [];\r\n const indices: Array<number> = [];\r\n const uvs: Array<number> = [];\r\n let meshCenter = Vector3.Zero();\r\n if (this._generator instanceof AbstractMesh && this._generator.hasBoundingInfo) {\r\n meshCenter = this._generator.getBoundingInfo().boundingBox.centerWorld;\r\n } else {\r\n meshCenter = this._generator.position;\r\n }\r\n const alpha: number = (2 * Math.PI) / this._sectionPolygonPointsCount;\r\n for (let i: number = 0; i <= this._sectionPolygonPointsCount; i++) {\r\n const angle = i !== this._sectionPolygonPointsCount ? i * alpha : 0;\r\n positions.push(meshCenter.x + Math.cos(angle) * this.diameter, meshCenter.y + Math.sin(angle) * this.diameter, meshCenter.z);\r\n uvs.push(i / this._sectionPolygonPointsCount, 0);\r\n }\r\n for (let i: number = 1; i <= this._length; i++) {\r\n for (let j: number = 0; j <= this._sectionPolygonPointsCount; j++) {\r\n const angle = j !== this._sectionPolygonPointsCount ? j * alpha : 0;\r\n positions.push(meshCenter.x + Math.cos(angle) * this.diameter, meshCenter.y + Math.sin(angle) * this.diameter, meshCenter.z);\r\n uvs.push(j / this._sectionPolygonPointsCount, i / this._length);\r\n }\r\n const l: number = positions.length / 3 - 2 * (this._sectionPolygonPointsCount + 1);\r\n for (let j: number = 0; j <= this._sectionPolygonPointsCount; j++) {\r\n indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);\r\n indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);\r\n }\r\n }\r\n VertexData.ComputeNormals(positions, indices, normals);\r\n data.positions = positions;\r\n data.normals = normals;\r\n data.indices = indices;\r\n data.uvs = uvs;\r\n data.applyToMesh(this, true);\r\n if (this._autoStart) {\r\n this.start();\r\n }\r\n }\r\n\r\n /**\r\n * Start trailing mesh.\r\n */\r\n public start(): void {\r\n if (!this._running) {\r\n this._running = true;\r\n this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(() => {\r\n this.update();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Stop trailing mesh.\r\n */\r\n public stop(): void {\r\n if (this._beforeRenderObserver && this._running) {\r\n this._running = false;\r\n this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);\r\n }\r\n }\r\n\r\n /**\r\n * Update trailing mesh geometry.\r\n */\r\n public update(): void {\r\n const positions = this.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = this.getVerticesData(VertexBuffer.NormalKind);\r\n const wm = this._generator.getWorldMatrix();\r\n if (positions && normals) {\r\n for (let i: number = 3 * (this._sectionPolygonPointsCount + 1); i < positions.length; i++) {\r\n positions[i - 3 * (this._sectionPolygonPointsCount + 1)] = positions[i] - (normals[i] / this._length) * this.diameter;\r\n }\r\n for (let i: number = 3 * (this._sectionPolygonPointsCount + 1); i < normals.length; i++) {\r\n normals[i - 3 * (this._sectionPolygonPointsCount + 1)] = normals[i];\r\n }\r\n const l: number = positions.length - 3 * (this._sectionPolygonPointsCount + 1);\r\n const alpha: number = (2 * Math.PI) / this._sectionPolygonPointsCount;\r\n for (let i: number = 0; i <= this._sectionPolygonPointsCount; i++) {\r\n const angle = i !== this._sectionPolygonPointsCount ? i * alpha : 0;\r\n this._sectionVectors[i].copyFromFloats(Math.cos(angle) * this.diameter, Math.sin(angle) * this.diameter, 0);\r\n this._sectionNormalVectors[i].copyFromFloats(Math.cos(angle), Math.sin(angle), 0);\r\n Vector3.TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);\r\n Vector3.TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);\r\n }\r\n for (let i: number = 0; i <= this._sectionPolygonPointsCount; i++) {\r\n positions[l + 3 * i] = this._sectionVectors[i].x;\r\n positions[l + 3 * i + 1] = this._sectionVectors[i].y;\r\n positions[l + 3 * i + 2] = this._sectionVectors[i].z;\r\n normals[l + 3 * i] = this._sectionNormalVectors[i].x;\r\n normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;\r\n normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;\r\n }\r\n this.updateVerticesData(VertexBuffer.PositionKind, positions, true, false);\r\n this.updateVerticesData(VertexBuffer.NormalKind, normals, true, false);\r\n }\r\n }\r\n\r\n /**\r\n * Returns a new TrailMesh object.\r\n * @param name is a string, the name given to the new mesh\r\n * @param newGenerator use new generator object for cloned trail mesh\r\n * @returns a new mesh\r\n */\r\n public clone(name: string = \"\", newGenerator: TransformNode): TrailMesh {\r\n return new TrailMesh(name, newGenerator ?? this._generator, this.getScene(), this.diameter, this._length, this._autoStart);\r\n }\r\n\r\n /**\r\n * Serializes this trail mesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n\r\n serializationObject.generatorId = this._generator.id;\r\n }\r\n\r\n /**\r\n * Parses a serialized trail mesh\r\n * @param parsedMesh the serialized mesh\r\n * @param scene the scene to create the trail mesh in\r\n * @returns the created trail mesh\r\n */\r\n public static Parse(parsedMesh: any, scene: Scene): TrailMesh {\r\n const generator = scene.getLastMeshById(parsedMesh.generatorId) ?? scene.getLastTransformNodeById(parsedMesh.generatorId);\r\n\r\n if (!generator) {\r\n throw new Error(\"TrailMesh: generator not found with ID \" + parsedMesh.generatorId);\r\n }\r\n\r\n return new TrailMesh(parsedMesh.name, generator, scene, parsedMesh.diameter ?? parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);\r\n }\r\n}\r\n"]}
|
|
@@ -219,7 +219,6 @@ export class HavokPlugin {
|
|
|
219
219
|
*/
|
|
220
220
|
this.name = "HavokPlugin";
|
|
221
221
|
this._fixedTimeStep = 1 / 60;
|
|
222
|
-
this._timeStep = 1 / 60;
|
|
223
222
|
this._tmpVec3 = ArrayTools.BuildArray(3, Vector3.Zero);
|
|
224
223
|
this._bodies = new Map();
|
|
225
224
|
this._shapes = new Map();
|
|
@@ -304,7 +303,9 @@ export class HavokPlugin {
|
|
|
304
303
|
}
|
|
305
304
|
this.setPhysicsBodyTransformation(physicsBody, physicsBody.transformNode);
|
|
306
305
|
}
|
|
307
|
-
|
|
306
|
+
const deltaTime = this._useDeltaForWorldStep ? delta : this._fixedTimeStep;
|
|
307
|
+
this._hknp.HP_World_SetIdealStepTime(this.world, deltaTime);
|
|
308
|
+
this._hknp.HP_World_Step(this.world, deltaTime);
|
|
308
309
|
this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1];
|
|
309
310
|
for (const physicsBody of physicsBodies) {
|
|
310
311
|
this.sync(physicsBody);
|