@onerjs/core 8.31.0 → 8.31.2

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.
Files changed (124) hide show
  1. package/Animations/animationGroup.js +1 -4
  2. package/Animations/animationGroup.js.map +1 -1
  3. package/Behaviors/Cameras/interpolatingBehavior.d.ts +8 -2
  4. package/Behaviors/Cameras/interpolatingBehavior.js +58 -6
  5. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  6. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +11 -9
  7. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
  8. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
  9. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
  10. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
  11. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
  12. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  13. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +8 -20
  14. package/Cameras/Inputs/geospatialCameraPointersInput.js +35 -75
  15. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  16. package/Cameras/Limits/geospatialLimits.d.ts +60 -0
  17. package/Cameras/Limits/geospatialLimits.js +89 -0
  18. package/Cameras/Limits/geospatialLimits.js.map +1 -0
  19. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +1 -1
  20. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
  21. package/Cameras/VR/vrExperienceHelper.js +2 -2
  22. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  23. package/Cameras/cameraMovement.js +1 -1
  24. package/Cameras/cameraMovement.js.map +1 -1
  25. package/Cameras/deviceOrientationCamera.js +5 -3
  26. package/Cameras/deviceOrientationCamera.js.map +1 -1
  27. package/Cameras/flyCamera.d.ts +2 -1
  28. package/Cameras/flyCamera.js.map +1 -1
  29. package/Cameras/geospatialCamera.d.ts +78 -49
  30. package/Cameras/geospatialCamera.js +210 -191
  31. package/Cameras/geospatialCamera.js.map +1 -1
  32. package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
  33. package/Cameras/geospatialCameraInputsManager.js +9 -0
  34. package/Cameras/geospatialCameraInputsManager.js.map +1 -1
  35. package/Cameras/geospatialCameraMovement.d.ts +66 -0
  36. package/Cameras/geospatialCameraMovement.js +199 -0
  37. package/Cameras/geospatialCameraMovement.js.map +1 -0
  38. package/Cameras/targetCamera.d.ts +1 -1
  39. package/Cameras/targetCamera.js +2 -2
  40. package/Cameras/targetCamera.js.map +1 -1
  41. package/Engines/Native/nativeInterfaces.d.ts +14 -6
  42. package/Engines/Native/nativeInterfaces.js +6 -1
  43. package/Engines/Native/nativeInterfaces.js.map +1 -1
  44. package/Engines/abstractEngine.js +2 -2
  45. package/Engines/abstractEngine.js.map +1 -1
  46. package/Engines/nativeEngine.js +2 -2
  47. package/Engines/nativeEngine.js.map +1 -1
  48. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
  49. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
  50. package/FlowGraph/flowGraphMath.d.ts +25 -0
  51. package/FlowGraph/flowGraphMath.js +40 -0
  52. package/FlowGraph/flowGraphMath.js.map +1 -0
  53. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
  54. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  55. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
  56. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  57. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
  58. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  59. package/Materials/shaderMaterial.js +4 -2
  60. package/Materials/shaderMaterial.js.map +1 -1
  61. package/Maths/math.vector.functions.d.ts +5 -24
  62. package/Maths/math.vector.functions.js +32 -35
  63. package/Maths/math.vector.functions.js.map +1 -1
  64. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
  65. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
  66. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  67. package/Meshes/csg2.js +1 -1
  68. package/Meshes/csg2.js.map +1 -1
  69. package/Meshes/thinInstanceMesh.js +15 -0
  70. package/Meshes/thinInstanceMesh.js.map +1 -1
  71. package/Misc/fileTools.js.map +1 -1
  72. package/Misc/tools.d.ts +3 -0
  73. package/Misc/tools.js +43 -4
  74. package/Misc/tools.js.map +1 -1
  75. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
  76. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  77. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  78. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  79. package/Particles/Node/Blocks/systemBlock.d.ts +8 -8
  80. package/Particles/Node/Blocks/systemBlock.js +12 -12
  81. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  82. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  83. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  84. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  85. package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
  86. package/Particles/Node/nodeParticleBuildState.js +9 -7
  87. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  88. package/Particles/Node/nodeParticleSystemSet.helper.js +288 -149
  89. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  90. package/Particles/particle.d.ts +4 -0
  91. package/Particles/particle.js +2 -0
  92. package/Particles/particle.js.map +1 -1
  93. package/Particles/thinParticleSystem.d.ts +0 -4
  94. package/Particles/thinParticleSystem.function.d.ts +1 -1
  95. package/Particles/thinParticleSystem.function.js +9 -6
  96. package/Particles/thinParticleSystem.function.js.map +1 -1
  97. package/Particles/thinParticleSystem.js +1 -3
  98. package/Particles/thinParticleSystem.js.map +1 -1
  99. package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
  100. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  101. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  102. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  103. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
  104. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  105. package/Shaders/gaussianSplatting.vertex.js +3 -3
  106. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  107. package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
  108. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  109. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
  110. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  111. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  112. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  113. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
  114. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  115. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
  116. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  117. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  118. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  119. package/XR/webXRCamera.d.ts +5 -1
  120. package/XR/webXRCamera.js +2 -2
  121. package/XR/webXRCamera.js.map +1 -1
  122. package/XR/webXRExperienceHelper.js +1 -1
  123. package/XR/webXRExperienceHelper.js.map +1 -1
  124. package/package.json +1 -1
@@ -1,6 +1,5 @@
1
1
  import type { DeepImmutable } from "../types.js";
2
- import type { IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from "./math.like.js";
3
- import { Quaternion, Vector3 } from "./math.vector.js";
2
+ import type { IVector2Like, IVector3Like, IVector4Like } from "./math.like.js";
4
3
  /**
5
4
  * Creates a string representation of the IVector2Like
6
5
  * @param vector defines the IVector2Like to stringify
@@ -65,6 +64,10 @@ export declare function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutab
65
64
  * @returns the scaled vector
66
65
  */
67
66
  export declare function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T;
67
+ export declare function Vector3SubtractToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>, result: T): T;
68
+ export declare function Vector3CopyToRef<T extends IVector3Like>(source: IVector3Like, result: T): T;
69
+ export declare function Vector3LerpToRef<T extends IVector3Like>(start: T, end: T, amount: number, result: T): T;
70
+ export declare function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<T>, result: T): T;
68
71
  /**
69
72
  * Creates a string representation of the IVector3Like
70
73
  * @param vector defines the IVector3Like to stringify
@@ -86,25 +89,3 @@ export declare function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmuta
86
89
  * @returns a string with the IVector4Like coordinates.
87
90
  */
88
91
  export declare function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string;
89
- /**
90
- * Returns the angle in radians between two quaternions
91
- * @param q1 defines the first quaternion
92
- * @param q2 defines the second quaternion
93
- * @returns the angle in radians between the two quaternions
94
- */
95
- export declare function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number;
96
- /**
97
- * Creates a quaternion from two direction vectors
98
- * @param a defines the first direction vector
99
- * @param b defines the second direction vector
100
- * @returns the target quaternion
101
- */
102
- export declare function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion;
103
- /**
104
- * Creates a quaternion from two direction vectors
105
- * @param a defines the first direction vector
106
- * @param b defines the second direction vector
107
- * @param result defines the target quaternion
108
- * @returns the target quaternion
109
- */
110
- export declare function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT;
@@ -1,5 +1,3 @@
1
- import { Clamp } from "./math.scalar.functions.js";
2
- import { Quaternion, Vector3 } from "./math.vector.js";
3
1
  /**
4
2
  * Creates a string representation of the IVector2Like
5
3
  * @param vector defines the IVector2Like to stringify
@@ -94,6 +92,38 @@ export function Vector3ScaleInPlace(vector, scale) {
94
92
  vector.z *= scale;
95
93
  return vector;
96
94
  }
95
+ export function Vector3SubtractToRef(a, b, result) {
96
+ result.x = a.x - b.x;
97
+ result.y = a.y - b.y;
98
+ result.z = a.z - b.z;
99
+ return result;
100
+ }
101
+ export function Vector3CopyToRef(source, result) {
102
+ result.x = source.x;
103
+ result.y = source.y;
104
+ result.z = source.z;
105
+ return result;
106
+ }
107
+ export function Vector3LerpToRef(start, end, amount, result) {
108
+ result.x = start.x + (end.x - start.x) * amount;
109
+ result.y = start.y + (end.y - start.y) * amount;
110
+ result.z = start.z + (end.z - start.z) * amount;
111
+ return result;
112
+ }
113
+ export function Vector3NormalizeToRef(vector, result) {
114
+ const len = Vector3Length(vector);
115
+ if (len === 0) {
116
+ result.x = 0;
117
+ result.y = 0;
118
+ result.z = 0;
119
+ }
120
+ else {
121
+ result.x = vector.x / len;
122
+ result.y = vector.y / len;
123
+ result.z = vector.z / len;
124
+ }
125
+ return result;
126
+ }
97
127
  /**
98
128
  * Creates a string representation of the IVector3Like
99
129
  * @param vector defines the IVector3Like to stringify
@@ -121,37 +151,4 @@ export function Vector4Dot(a, b) {
121
151
  export function Vector4ToFixed(vector, decimalCount) {
122
152
  return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;
123
153
  }
124
- /**
125
- * Returns the angle in radians between two quaternions
126
- * @param q1 defines the first quaternion
127
- * @param q2 defines the second quaternion
128
- * @returns the angle in radians between the two quaternions
129
- */
130
- export function GetAngleBetweenQuaternions(q1, q2) {
131
- return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;
132
- }
133
- /**
134
- * Creates a quaternion from two direction vectors
135
- * @param a defines the first direction vector
136
- * @param b defines the second direction vector
137
- * @returns the target quaternion
138
- */
139
- export function GetQuaternionFromDirections(a, b) {
140
- const result = new Quaternion();
141
- GetQuaternionFromDirectionsToRef(a, b, result);
142
- return result;
143
- }
144
- /**
145
- * Creates a quaternion from two direction vectors
146
- * @param a defines the first direction vector
147
- * @param b defines the second direction vector
148
- * @param result defines the target quaternion
149
- * @returns the target quaternion
150
- */
151
- export function GetQuaternionFromDirectionsToRef(a, b, result) {
152
- const axis = Vector3.Cross(a, b);
153
- const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));
154
- Quaternion.RotationAxisToRef(axis, angle, result);
155
- return result;
156
- }
157
154
  //# sourceMappingURL=math.vector.functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC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O,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACnK,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAkC,EAAE,EAAkC;IAC7G,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAoB,CAAmB,EAAE,CAAmB;IACnG,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,gCAAgC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAgD,CAAmB,EAAE,CAAmB,EAAE,MAAe;IACrJ,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { Clamp } from \"./math.scalar.functions\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\nimport { Quaternion, Vector3 } from \"./math.vector\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the result vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the result vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n return vector;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Returns the angle in radians between two quaternions\r\n * @param q1 defines the first quaternion\r\n * @param q2 defines the second quaternion\r\n * @returns the angle in radians between the two quaternions\r\n */\r\nexport function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number {\r\n return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion {\r\n const result = new Quaternion();\r\n GetQuaternionFromDirectionsToRef(a, b, result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @param result defines the target quaternion\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT {\r\n const axis = Vector3.Cross(a, b);\r\n const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));\r\n Quaternion.RotationAxisToRef(axis, angle, result);\r\n return result;\r\n}\r\n"]}
1
+ {"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC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MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACnK,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport type { IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the result vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the result vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n return vector;\r\n}\r\n\r\nexport function Vector3SubtractToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>, result: T): T {\r\n result.x = a.x - b.x;\r\n result.y = a.y - b.y;\r\n result.z = a.z - b.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3CopyToRef<T extends IVector3Like>(source: IVector3Like, result: T): T {\r\n result.x = source.x;\r\n result.y = source.y;\r\n result.z = source.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3LerpToRef<T extends IVector3Like>(start: T, end: T, amount: number, result: T): T {\r\n result.x = start.x + (end.x - start.x) * amount;\r\n result.y = start.y + (end.y - start.y) * amount;\r\n result.z = start.z + (end.z - start.z) * amount;\r\n return result;\r\n}\r\n\r\nexport function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<T>, result: T): T {\r\n const len = Vector3Length(vector);\r\n if (len === 0) {\r\n result.x = 0;\r\n result.y = 0;\r\n result.z = 0;\r\n } else {\r\n result.x = vector.x / len;\r\n result.y = vector.y / len;\r\n result.z = vector.z / len;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n"]}
@@ -380,6 +380,7 @@ export declare class GaussianSplattingMesh extends Mesh {
380
380
  */
381
381
  clone(name?: string): GaussianSplattingMesh;
382
382
  private static _CreateWorker;
383
+ private _makeEmptySplat;
383
384
  private _makeSplat;
384
385
  private _updateTextures;
385
386
  private _updateData;
@@ -279,11 +279,27 @@ export class GaussianSplattingMesh extends Mesh {
279
279
  this._shDegree = 0;
280
280
  this._viewDirectionFactor = new Vector3(1, 1, -1);
281
281
  const vertexData = new VertexData();
282
- vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];
283
- vertexData.indices = [0, 1, 2, 0, 2, 3];
282
+ const originPositions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];
283
+ const originIndices = [0, 1, 2, 0, 2, 3];
284
+ const positions = [];
285
+ const indices = [];
286
+ const batchSize = 16; // 16 splats per instance
287
+ for (let i = 0; i < batchSize; i++) {
288
+ for (let j = 0; j < 12; j++) {
289
+ if (j == 2 || j == 5 || j == 8 || j == 11) {
290
+ positions.push(i); // local splat index
291
+ }
292
+ else {
293
+ positions.push(originPositions[j]);
294
+ }
295
+ }
296
+ indices.push(originIndices.map((v) => v + i * 4));
297
+ }
298
+ vertexData.positions = positions;
299
+ vertexData.indices = indices.flat();
284
300
  vertexData.applyToMesh(this);
285
301
  this.subMeshes = [];
286
- new SubMesh(0, 0, 4, 0, 6, this);
302
+ new SubMesh(0, 0, 4 * batchSize, 0, 6 * batchSize, this);
287
303
  this.setEnabled(false);
288
304
  // webGL2 and webGPU support for RG texture with float16 is fine. not webGL1
289
305
  this._useRGBACovariants = !this.getEngine().isWebGPU && this.getEngine().version === 1.0;
@@ -1077,10 +1093,23 @@ export class GaussianSplattingMesh extends Mesh {
1077
1093
  newGS._instanciateWorker();
1078
1094
  const binfo = this.getBoundingInfo();
1079
1095
  newGS.getBoundingInfo().reConstruct(binfo.minimum, binfo.maximum, this.getWorldMatrix());
1080
- newGS.forcedInstanceCount = newGS._vertexCount;
1096
+ newGS.forcedInstanceCount = this.forcedInstanceCount;
1081
1097
  newGS.setEnabled(true);
1082
1098
  return newGS;
1083
1099
  }
1100
+ _makeEmptySplat(index, covA, covB, colorArray) {
1101
+ const covBSItemSize = this._useRGBACovariants ? 4 : 2;
1102
+ this._splatPositions[4 * index + 0] = 0;
1103
+ this._splatPositions[4 * index + 1] = 0;
1104
+ this._splatPositions[4 * index + 2] = 0;
1105
+ covA[index * 4 + 0] = ToHalfFloat(0);
1106
+ covA[index * 4 + 1] = ToHalfFloat(0);
1107
+ covA[index * 4 + 2] = ToHalfFloat(0);
1108
+ covA[index * 4 + 3] = ToHalfFloat(0);
1109
+ covB[index * covBSItemSize + 0] = ToHalfFloat(0);
1110
+ covB[index * covBSItemSize + 1] = ToHalfFloat(0);
1111
+ colorArray[index * 4 + 3] = 0;
1112
+ }
1084
1113
  _makeSplat(index, fBuffer, uBuffer, covA, covB, colorArray, minimum, maximum) {
1085
1114
  const matrixRotation = TmpVectors.Matrix[0];
1086
1115
  const matrixScale = TmpVectors.Matrix[1];
@@ -1221,12 +1250,17 @@ export class GaussianSplattingMesh extends Mesh {
1221
1250
  this._sortIsDirty = true;
1222
1251
  }
1223
1252
  else {
1253
+ const paddedVertexCount = (vertexCount + 15) & ~0xf;
1224
1254
  for (let i = 0; i < vertexCount; i++) {
1225
1255
  this._makeSplat(i, fBuffer, uBuffer, covA, covB, colorArray, minimum, maximum);
1226
1256
  if (isAsync && i % GaussianSplattingMesh._SplatBatchSize === 0) {
1227
1257
  yield;
1228
1258
  }
1229
1259
  }
1260
+ // pad the rest
1261
+ for (let i = vertexCount; i < paddedVertexCount; i++) {
1262
+ this._makeEmptySplat(i, covA, covB, colorArray);
1263
+ }
1230
1264
  // textures
1231
1265
  this._updateTextures(covA, covB, colorArray, sh);
1232
1266
  // Update the binfo
@@ -1263,11 +1297,12 @@ export class GaussianSplattingMesh extends Mesh {
1263
1297
  }
1264
1298
  // in case size is different
1265
1299
  _updateSplatIndexBuffer(vertexCount) {
1300
+ const paddedVertexCount = (vertexCount + 15) & ~0xf;
1266
1301
  if (!this._splatIndex || vertexCount > this._splatIndex.length) {
1267
- this._splatIndex = new Float32Array(vertexCount);
1268
- this.thinInstanceSetBuffer("splatIndex", this._splatIndex, 1, false);
1302
+ this._splatIndex = new Float32Array(paddedVertexCount);
1303
+ this.thinInstanceSetBuffer("splatIndex", this._splatIndex, 16, false);
1269
1304
  }
1270
- this.forcedInstanceCount = vertexCount;
1305
+ this.forcedInstanceCount = paddedVertexCount >> 4;
1271
1306
  }
1272
1307
  _updateSubTextures(centers, covA, covB, colors, lineStart, lineCount, sh) {
1273
1308
  const updateTextureFromData = (texture, data, width, lineStart, lineCount) => {
@@ -1303,20 +1338,20 @@ export class GaussianSplattingMesh extends Mesh {
1303
1338
  this._worker = new Worker(URL.createObjectURL(new Blob(["(", GaussianSplattingMesh._CreateWorker.toString(), ")(self)"], {
1304
1339
  type: "application/javascript",
1305
1340
  })));
1306
- this._depthMix = new BigInt64Array(this._vertexCount);
1341
+ const vertexCountPadded = (this._vertexCount + 15) & ~0xf;
1342
+ this._depthMix = new BigInt64Array(vertexCountPadded);
1307
1343
  const positions = Float32Array.from(this._splatPositions);
1308
- const vertexCount = this._vertexCount;
1309
- this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
1344
+ this._worker.postMessage({ positions, vertexCountPadded }, [positions.buffer]);
1310
1345
  this._worker.onmessage = (e) => {
1311
1346
  this._depthMix = e.data.depthMix;
1312
1347
  const indexMix = new Uint32Array(e.data.depthMix.buffer);
1313
1348
  if (this._splatIndex) {
1314
- for (let j = 0; j < this._vertexCount; j++) {
1349
+ for (let j = 0; j < vertexCountPadded; j++) {
1315
1350
  this._splatIndex[j] = indexMix[2 * j];
1316
1351
  }
1317
1352
  }
1318
1353
  if (this._delayedTextureUpdate) {
1319
- const textureSize = this._getTextureSize(vertexCount);
1354
+ const textureSize = this._getTextureSize(vertexCountPadded);
1320
1355
  this._updateSubTextures(this._delayedTextureUpdate.centers, this._delayedTextureUpdate.covA, this._delayedTextureUpdate.covB, this._delayedTextureUpdate.colors, 0, textureSize.y, this._delayedTextureUpdate.sh);
1321
1356
  this._delayedTextureUpdate = null;
1322
1357
  }
@@ -1363,7 +1398,7 @@ GaussianSplattingMesh._PlyConversionBatchSize = 32768;
1363
1398
  */
1364
1399
  GaussianSplattingMesh.ProgressiveUpdateAmount = 0;
1365
1400
  GaussianSplattingMesh._CreateWorker = function (self) {
1366
- let vertexCount = 0;
1401
+ let vertexCountPadded = 0;
1367
1402
  let positions;
1368
1403
  let depthMix;
1369
1404
  let indices;
@@ -1372,7 +1407,7 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1372
1407
  // updated on init
1373
1408
  if (e.data.positions) {
1374
1409
  positions = e.data.positions;
1375
- vertexCount = e.data.vertexCount;
1410
+ vertexCountPadded = e.data.vertexCountPadded;
1376
1411
  }
1377
1412
  // udpate on view changed
1378
1413
  else {
@@ -1385,14 +1420,14 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1385
1420
  indices = new Uint32Array(depthMix.buffer);
1386
1421
  floatMix = new Float32Array(depthMix.buffer);
1387
1422
  // Sort
1388
- for (let j = 0; j < vertexCount; j++) {
1423
+ for (let j = 0; j < vertexCountPadded; j++) {
1389
1424
  indices[2 * j] = j;
1390
1425
  }
1391
1426
  let depthFactor = -1;
1392
1427
  if (e.data.useRightHandedSystem) {
1393
1428
  depthFactor = 1;
1394
1429
  }
1395
- for (let j = 0; j < vertexCount; j++) {
1430
+ for (let j = 0; j < vertexCountPadded; j++) {
1396
1431
  floatMix[2 * j + 1] = 10000 + (viewProj[2] * positions[4 * j + 0] + viewProj[6] * positions[4 * j + 1] + viewProj[10] * positions[4 * j + 2]) * depthFactor;
1397
1432
  }
1398
1433
  depthMix.sort();