@onerjs/core 8.30.5 → 8.30.7

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 (219) hide show
  1. package/Actions/action.d.ts +5 -0
  2. package/Actions/action.js.map +1 -1
  3. package/Actions/actionManager.js +6 -2
  4. package/Actions/actionManager.js.map +1 -1
  5. package/Animations/runtimeAnimation.d.ts +0 -2
  6. package/Animations/runtimeAnimation.js +3 -5
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/AudioV2/abstractAudio/abstractSound.js +1 -0
  9. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  10. package/AudioV2/abstractAudio/audioEngineV2.d.ts +2 -0
  11. package/AudioV2/abstractAudio/audioEngineV2.js +18 -8
  12. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  13. package/AudioV2/webAudio/webAudioStaticSound.js +8 -3
  14. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  15. package/Collisions/gpuPicker.js +0 -1
  16. package/Collisions/gpuPicker.js.map +1 -1
  17. package/Debug/debugLayer.d.ts +1 -1
  18. package/Debug/debugLayer.js.map +1 -1
  19. package/Decorators/nodeDecorator.d.ts +3 -1
  20. package/Decorators/nodeDecorator.js +2 -0
  21. package/Decorators/nodeDecorator.js.map +1 -1
  22. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  23. package/Engines/Native/nativeInterfaces.js.map +1 -1
  24. package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
  25. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  26. package/Engines/abstractEngine.js +2 -2
  27. package/Engines/abstractEngine.js.map +1 -1
  28. package/Engines/nativeEngine.js +12 -13
  29. package/Engines/nativeEngine.js.map +1 -1
  30. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
  31. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
  32. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
  33. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
  34. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
  35. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  36. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
  37. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
  38. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
  39. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
  40. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
  41. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
  42. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
  43. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
  44. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
  46. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +2 -2
  47. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
  48. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
  49. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
  50. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
  51. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
  52. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
  53. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
  54. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
  55. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
  56. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
  57. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
  58. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
  59. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
  60. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
  61. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
  62. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
  63. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
  64. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
  65. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
  66. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
  67. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
  68. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
  69. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
  70. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
  71. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
  72. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
  73. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
  74. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
  75. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
  76. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
  77. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
  78. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
  79. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
  80. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
  81. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
  82. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
  83. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
  84. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
  85. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
  86. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
  87. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
  88. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
  89. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
  90. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
  91. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
  92. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
  93. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
  94. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +20 -1
  95. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +83 -0
  96. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  97. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  98. package/FrameGraph/Node/Blocks/index.js +1 -0
  99. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  100. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
  101. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
  102. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  103. package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
  104. package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
  105. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
  106. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
  107. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
  108. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
  109. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
  110. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  111. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
  112. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
  113. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
  114. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
  115. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
  116. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
  117. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +11 -1
  118. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +10 -1
  119. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  120. package/FrameGraph/frameGraphContext.d.ts +8 -1
  121. package/FrameGraph/frameGraphContext.js +9 -0
  122. package/FrameGraph/frameGraphContext.js.map +1 -1
  123. package/FrameGraph/frameGraphRenderContext.d.ts +5 -2
  124. package/FrameGraph/frameGraphRenderContext.js +32 -7
  125. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  126. package/FrameGraph/frameGraphTask.d.ts +8 -0
  127. package/FrameGraph/frameGraphTask.js +12 -0
  128. package/FrameGraph/frameGraphTask.js.map +1 -1
  129. package/Materials/PBR/openpbrMaterial.js +2 -1
  130. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  131. package/Materials/Textures/mirrorTexture.js +4 -1
  132. package/Materials/Textures/mirrorTexture.js.map +1 -1
  133. package/Materials/clipPlaneMaterialHelper.js +11 -1
  134. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  135. package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
  136. package/Materials/floatingOriginMatrixOverrides.js +14 -2
  137. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  138. package/Materials/index.d.ts +1 -0
  139. package/Materials/index.js +1 -0
  140. package/Materials/index.js.map +1 -1
  141. package/Materials/shaderMaterial.js +1 -1
  142. package/Materials/shaderMaterial.js.map +1 -1
  143. package/Maths/math.vector.functions.d.ts +31 -5
  144. package/Maths/math.vector.functions.js +41 -4
  145. package/Maths/math.vector.functions.js.map +1 -1
  146. package/Meshes/Node/Blocks/randomBlock.js +11 -11
  147. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  148. package/Misc/copyTextureToTexture.d.ts +18 -1
  149. package/Misc/copyTextureToTexture.js +31 -2
  150. package/Misc/copyTextureToTexture.js.map +1 -1
  151. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
  152. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  153. package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
  154. package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
  155. package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
  156. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
  157. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  158. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
  159. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  160. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
  161. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  162. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
  163. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  164. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
  165. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  166. package/Particles/Node/Blocks/particleRandomBlock.js +10 -10
  167. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  168. package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
  169. package/Particles/Node/Blocks/systemBlock.js +83 -3
  170. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  171. package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
  172. package/Particles/Node/nodeParticleBuildState.js +7 -22
  173. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  174. package/Particles/Node/nodeParticleSystemSet.helper.js +224 -58
  175. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  176. package/Particles/Node/nodeParticleSystemSet.js +1 -1
  177. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  178. package/Particles/thinParticleSystem.js +1 -0
  179. package/Particles/thinParticleSystem.js.map +1 -1
  180. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
  181. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  182. package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
  183. package/Physics/v2/Plugins/havokPlugin.js +72 -8
  184. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  185. package/Physics/v2/physicsEngine.d.ts +12 -2
  186. package/Physics/v2/physicsEngine.js +15 -1
  187. package/Physics/v2/physicsEngine.js.map +1 -1
  188. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
  189. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  190. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -0
  191. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  192. package/Shaders/copyTextureToTexture.fragment.js +2 -2
  193. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  194. package/Shaders/picking.fragment.js +1 -1
  195. package/Shaders/picking.fragment.js.map +1 -1
  196. package/Shaders/picking.vertex.js +1 -1
  197. package/Shaders/picking.vertex.js.map +1 -1
  198. package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
  199. package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
  200. package/ShadersWGSL/iblVoxelGrid.vertex.js +1 -1
  201. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  202. package/ShadersWGSL/picking.fragment.js +1 -1
  203. package/ShadersWGSL/picking.fragment.js.map +1 -1
  204. package/ShadersWGSL/picking.vertex.js +1 -1
  205. package/ShadersWGSL/picking.vertex.js.map +1 -1
  206. package/Sprites/spriteRenderer.js +10 -8
  207. package/Sprites/spriteRenderer.js.map +1 -1
  208. package/XR/features/WebXRLightEstimation.d.ts +8 -0
  209. package/XR/features/WebXRLightEstimation.js +6 -1
  210. package/XR/features/WebXRLightEstimation.js.map +1 -1
  211. package/XR/webXRSessionManager.js +4 -0
  212. package/XR/webXRSessionManager.js.map +1 -1
  213. package/assetContainer.d.ts +1 -1
  214. package/assetContainer.js +1 -1
  215. package/assetContainer.js.map +1 -1
  216. package/package.json +1 -1
  217. package/scene.d.ts +5 -2
  218. package/scene.js +9 -14
  219. package/scene.js.map +1 -1
@@ -7,7 +7,7 @@ import { Quaternion, Vector3 } from "./math.vector.js";
7
7
  * @param decimalCount defines the number of decimals to use
8
8
  * @returns a string with the IVector2Like coordinates.
9
9
  */
10
- export declare function Vector2ToFixed(vector: IVector2Like, decimalCount: number): string;
10
+ export declare function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string;
11
11
  /**
12
12
  * Computes the dot product of two IVector3Like objects.
13
13
  * @param a defines the first vector
@@ -15,12 +15,38 @@ export declare function Vector2ToFixed(vector: IVector2Like, decimalCount: numbe
15
15
  * @returns the dot product
16
16
  */
17
17
  export declare function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
18
+ /**
19
+ * Computes the squared length of the IVector3Like
20
+ * @param vector the vector to measure
21
+ * @returns the squared length of the vector
22
+ */
23
+ export declare function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number;
24
+ /**
25
+ * Computes the length of the IVector3Like
26
+ * @param vector the vector to measure
27
+ * @returns the length of the vector
28
+ */
29
+ export declare function Vector3Length(vector: DeepImmutable<IVector3Like>): number;
30
+ /**
31
+ * Computes the squared distance between the IVector3Like objects
32
+ * @param a defines the first vector
33
+ * @param b defines the second vector
34
+ * @returns the squared distance
35
+ */
36
+ export declare function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
37
+ /**
38
+ * Computes the distance between the IVector3Like objects
39
+ * @param a defines the first vector
40
+ * @param b defines the second vector
41
+ * @returns the distance
42
+ */
43
+ export declare function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
18
44
  /**
19
45
  * Sets the given floats into the result.
20
46
  * @param x defines the x coordinate
21
47
  * @param y defines the y coordinate
22
48
  * @param z defines the z coordinate
23
- * @param result defines the target vector
49
+ * @param result defines the result vector
24
50
  * @returns the result vector
25
51
  */
26
52
  export declare function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T;
@@ -28,15 +54,15 @@ export declare function Vector3FromFloatsToRef<T extends IVector3Like>(x: number
28
54
  * Stores the scaled values of a vector into the result.
29
55
  * @param a defines the source vector
30
56
  * @param scale defines the scale factor
31
- * @param result defines the target vector
57
+ * @param result defines the result vector
32
58
  * @returns the scaled vector
33
59
  */
34
60
  export declare function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T;
35
61
  /**
36
- * Scales the current vector values in place by a factor
62
+ * Scales the current vector values in place by a factor.
37
63
  * @param vector defines the vector to scale
38
64
  * @param scale defines the scale factor
39
- * @returns the input scaled vector
65
+ * @returns the scaled vector
40
66
  */
41
67
  export declare function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T;
42
68
  /**
@@ -18,12 +18,49 @@ export function Vector2ToFixed(vector, decimalCount) {
18
18
  export function Vector3Dot(a, b) {
19
19
  return a.x * b.x + a.y * b.y + a.z * b.z;
20
20
  }
21
+ /**
22
+ * Computes the squared length of the IVector3Like
23
+ * @param vector the vector to measure
24
+ * @returns the squared length of the vector
25
+ */
26
+ export function Vector3LengthSquared(vector) {
27
+ return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
28
+ }
29
+ /**
30
+ * Computes the length of the IVector3Like
31
+ * @param vector the vector to measure
32
+ * @returns the length of the vector
33
+ */
34
+ export function Vector3Length(vector) {
35
+ return Math.sqrt(Vector3LengthSquared(vector));
36
+ }
37
+ /**
38
+ * Computes the squared distance between the IVector3Like objects
39
+ * @param a defines the first vector
40
+ * @param b defines the second vector
41
+ * @returns the squared distance
42
+ */
43
+ export function Vector3DistanceSquared(a, b) {
44
+ const x = b.x - a.x;
45
+ const y = b.y - a.y;
46
+ const z = b.z - a.z;
47
+ return x * x + y * y + z * z;
48
+ }
49
+ /**
50
+ * Computes the distance between the IVector3Like objects
51
+ * @param a defines the first vector
52
+ * @param b defines the second vector
53
+ * @returns the distance
54
+ */
55
+ export function Vector3Distance(a, b) {
56
+ return Math.sqrt(Vector3DistanceSquared(a, b));
57
+ }
21
58
  /**
22
59
  * Sets the given floats into the result.
23
60
  * @param x defines the x coordinate
24
61
  * @param y defines the y coordinate
25
62
  * @param z defines the z coordinate
26
- * @param result defines the target vector
63
+ * @param result defines the result vector
27
64
  * @returns the result vector
28
65
  */
29
66
  export function Vector3FromFloatsToRef(x, y, z, result) {
@@ -36,7 +73,7 @@ export function Vector3FromFloatsToRef(x, y, z, result) {
36
73
  * Stores the scaled values of a vector into the result.
37
74
  * @param a defines the source vector
38
75
  * @param scale defines the scale factor
39
- * @param result defines the target vector
76
+ * @param result defines the result vector
40
77
  * @returns the scaled vector
41
78
  */
42
79
  export function Vector3ScaleToRef(a, scale, result) {
@@ -46,10 +83,10 @@ export function Vector3ScaleToRef(a, scale, result) {
46
83
  return result;
47
84
  }
48
85
  /**
49
- * Scales the current vector values in place by a factor
86
+ * Scales the current vector values in place by a factor.
50
87
  * @param vector defines the vector to scale
51
88
  * @param scale defines the scale factor
52
- * @returns the input scaled vector
89
+ * @returns the scaled vector
53
90
  */
54
91
  export function Vector3ScaleInPlace(vector, scale) {
55
92
  vector.x *= scale;
@@ -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,MAAoB,EAAE,YAAoB;IACrE,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,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAA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;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: 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 * 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 target 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 target 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 input 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":"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,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MA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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"]}
@@ -93,32 +93,32 @@ export class RandomBlock extends NodeGeometryBlock {
93
93
  case NodeGeometryBlockConnectionPointTypes.Int:
94
94
  case NodeGeometryBlockConnectionPointTypes.Float: {
95
95
  func = (state) => {
96
- const min = this.min.getConnectedValue(state) || 0;
97
- const max = this.max.getConnectedValue(state) || 0;
96
+ const min = this.min.getConnectedValue(state) ?? 0;
97
+ const max = this.max.getConnectedValue(state) ?? 0;
98
98
  return min + Math.random() * (max - min);
99
99
  };
100
100
  break;
101
101
  }
102
102
  case NodeGeometryBlockConnectionPointTypes.Vector2: {
103
103
  func = (state) => {
104
- const min = this.min.getConnectedValue(state) || Vector2.Zero();
105
- const max = this.max.getConnectedValue(state) || Vector2.Zero();
104
+ const min = this.min.getConnectedValue(state) ?? Vector2.Zero();
105
+ const max = this.max.getConnectedValue(state) ?? Vector2.Zero();
106
106
  return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));
107
107
  };
108
108
  break;
109
109
  }
110
110
  case NodeGeometryBlockConnectionPointTypes.Vector3: {
111
111
  func = (state) => {
112
- const min = this.min.getConnectedValue(state) || Vector3.Zero();
113
- const max = this.max.getConnectedValue(state) || Vector3.Zero();
112
+ const min = this.min.getConnectedValue(state) ?? Vector3.Zero();
113
+ const max = this.max.getConnectedValue(state) ?? Vector3.Zero();
114
114
  return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));
115
115
  };
116
116
  break;
117
117
  }
118
118
  case NodeGeometryBlockConnectionPointTypes.Vector4: {
119
119
  func = (state) => {
120
- const min = this.min.getConnectedValue(state) || Vector4.Zero();
121
- const max = this.max.getConnectedValue(state) || Vector4.Zero();
120
+ const min = this.min.getConnectedValue(state) ?? Vector4.Zero();
121
+ const max = this.max.getConnectedValue(state) ?? Vector4.Zero();
122
122
  return new Vector4(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z), min.w + Math.random() * (max.w - min.w));
123
123
  };
124
124
  break;
@@ -132,13 +132,13 @@ export class RandomBlock extends NodeGeometryBlock {
132
132
  let lockId = 0;
133
133
  switch (this.lockMode) {
134
134
  case RandomBlockLocks.InstanceID:
135
- lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) || 0;
135
+ lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) ?? 0;
136
136
  break;
137
137
  case RandomBlockLocks.LoopID:
138
- lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) || 0;
138
+ lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) ?? 0;
139
139
  break;
140
140
  case RandomBlockLocks.Once:
141
- lockId = state.buildId || 0;
141
+ lockId = state.buildId ?? 0;
142
142
  break;
143
143
  }
144
144
  if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {
@@ -1 +1 @@
1
- {"version":3,"file":"randomBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/randomBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAA0B,sBAAsB,EAAE,6CAAsC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IACxB,WAAW;IACX,uDAAI,CAAA;IACJ,aAAa;IACb,gEAAgE;IAChE,2DAAM,CAAA;IACN,iBAAiB;IACjB,gEAAgE;IAChE,mEAAU,CAAA;IACV,WAAW;IACX,uDAAI,CAAA;AACR,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B;AAED;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAiB9C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QArBR,mBAAc,GAAG,CAAC,CAAC,CAAC;QAC5B;;WAEG;QAWI,aAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC;QASpC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,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CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACJ;AAlKU;IAVN,sBAAsB,CAAC,UAAU,uCAA+B,UAAU,EAAE;QACzE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;YAC/C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE;YACnD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,CAAC,UAAU,EAAE;YAC3D,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;SAClD;KACJ,CAAC;6CACsC;AAoK5C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { GeometryInputBlock } from \"./geometryInputBlock\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Locks supported by the random block\r\n */\r\nexport enum RandomBlockLocks {\r\n /** None */\r\n None,\r\n /** LoopID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n LoopID,\r\n /** InstanceID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n InstanceID,\r\n /** Once */\r\n Once,\r\n}\r\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\r\n private _currentLockId = -1;\r\n /**\r\n * Gets or sets a value indicating if that block will lock its value for a specific duration\r\n */\r\n @editableInPropertyPage(\"LockMode\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"None\", value: RandomBlockLocks.None },\r\n { label: \"LoopID\", value: RandomBlockLocks.LoopID },\r\n { label: \"InstanceID\", value: RandomBlockLocks.InstanceID },\r\n { label: \"Once\", value: RandomBlockLocks.Once },\r\n ],\r\n })\r\n public lockMode = RandomBlockLocks.None;\r\n\r\n /**\r\n * Create a new RandomBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"min\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"max\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RandomBlock\";\r\n }\r\n\r\n /**\r\n * Gets the min input component\r\n */\r\n public get min(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the max input component\r\n */\r\n public get max(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.min.isConnected) {\r\n const minInput = new GeometryInputBlock(\"Min\");\r\n minInput.value = 0;\r\n minInput.output.connectTo(this.min);\r\n }\r\n\r\n if (!this.max.isConnected) {\r\n const maxInput = new GeometryInputBlock(\"Max\");\r\n maxInput.value = 1;\r\n maxInput.output.connectTo(this.max);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n this._currentLockId = -1;\r\n\r\n switch (this.min.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || 0;\r\n const max = this.max.getConnectedValue(state) || 0;\r\n return min + Math.random() * (max - min);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector2.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector2.Zero();\r\n return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector3.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector3.Zero();\r\n return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector4.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector4.Zero();\r\n return new Vector4(\r\n min.x + Math.random() * (max.x - min.x),\r\n min.y + Math.random() * (max.y - min.y),\r\n min.z + Math.random() * (max.z - min.z),\r\n min.w + Math.random() * (max.w - min.w)\r\n );\r\n };\r\n break;\r\n }\r\n }\r\n\r\n if (this.lockMode === RandomBlockLocks.None || !func) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = (state) => {\r\n let lockId = 0;\r\n\r\n switch (this.lockMode) {\r\n case RandomBlockLocks.InstanceID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) || 0;\r\n break;\r\n case RandomBlockLocks.LoopID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) || 0;\r\n break;\r\n case RandomBlockLocks.Once:\r\n lockId = state.buildId || 0;\r\n break;\r\n }\r\n\r\n if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {\r\n this._currentLockId = lockId;\r\n this.output._storedValue = func(state);\r\n }\r\n return this.output._storedValue;\r\n };\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockMode = BABYLON.RandomBlockLocks.${RandomBlockLocks[this.lockMode]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.lockMode = this.lockMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.lockMode = serializationObject.lockMode;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
1
+ {"version":3,"file":"randomBlock.js","source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C5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;YAC/C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE;YACnD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,CAAC,UAAU,EAAE;YAC3D,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;SAClD;KACJ,CAAC;6CACsC;AAoK5C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { GeometryInputBlock } from \"./geometryInputBlock\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Locks supported by the random block\r\n */\r\nexport enum RandomBlockLocks {\r\n /** None */\r\n None,\r\n /** LoopID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n LoopID,\r\n /** InstanceID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n InstanceID,\r\n /** Once */\r\n Once,\r\n}\r\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\r\n private _currentLockId = -1;\r\n /**\r\n * Gets or sets a value indicating if that block will lock its value for a specific duration\r\n */\r\n @editableInPropertyPage(\"LockMode\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"None\", value: RandomBlockLocks.None },\r\n { label: \"LoopID\", value: RandomBlockLocks.LoopID },\r\n { label: \"InstanceID\", value: RandomBlockLocks.InstanceID },\r\n { label: \"Once\", value: RandomBlockLocks.Once },\r\n ],\r\n })\r\n public lockMode = RandomBlockLocks.None;\r\n\r\n /**\r\n * Create a new RandomBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"min\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"max\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RandomBlock\";\r\n }\r\n\r\n /**\r\n * Gets the min input component\r\n */\r\n public get min(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the max input component\r\n */\r\n public get max(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.min.isConnected) {\r\n const minInput = new GeometryInputBlock(\"Min\");\r\n minInput.value = 0;\r\n minInput.output.connectTo(this.min);\r\n }\r\n\r\n if (!this.max.isConnected) {\r\n const maxInput = new GeometryInputBlock(\"Max\");\r\n maxInput.value = 1;\r\n maxInput.output.connectTo(this.max);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n this._currentLockId = -1;\r\n\r\n switch (this.min.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? 0;\r\n const max = this.max.getConnectedValue(state) ?? 0;\r\n return min + Math.random() * (max - min);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector2.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector2.Zero();\r\n return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector3.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector3.Zero();\r\n return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector4.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector4.Zero();\r\n return new Vector4(\r\n min.x + Math.random() * (max.x - min.x),\r\n min.y + Math.random() * (max.y - min.y),\r\n min.z + Math.random() * (max.z - min.z),\r\n min.w + Math.random() * (max.w - min.w)\r\n );\r\n };\r\n break;\r\n }\r\n }\r\n\r\n if (this.lockMode === RandomBlockLocks.None || !func) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = (state) => {\r\n let lockId = 0;\r\n\r\n switch (this.lockMode) {\r\n case RandomBlockLocks.InstanceID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) ?? 0;\r\n break;\r\n case RandomBlockLocks.LoopID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) ?? 0;\r\n break;\r\n case RandomBlockLocks.Once:\r\n lockId = state.buildId ?? 0;\r\n break;\r\n }\r\n\r\n if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {\r\n this._currentLockId = lockId;\r\n this.output._storedValue = func(state);\r\n }\r\n return this.output._storedValue;\r\n };\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockMode = BABYLON.RandomBlockLocks.${RandomBlockLocks[this.lockMode]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.lockMode = this.lockMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.lockMode = serializationObject.lockMode;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { AbstractEngine } from "../Engines/abstractEngine.js";
2
2
  import type { InternalTexture } from "../Materials/Textures/internalTexture.js";
3
+ import { EffectWrapper } from "../Materials/effectRenderer.js";
3
4
  import type { IRenderTargetTexture, RenderTargetWrapper } from "../Engines/renderTargetWrapper.js";
4
5
  import type { ThinTexture } from "../Materials/Textures/thinTexture.js";
5
6
  import type { Nullable } from "../types.js";
@@ -22,12 +23,27 @@ export declare class CopyTextureToTexture {
22
23
  private _effectWrapper;
23
24
  private _source;
24
25
  private _conversion;
26
+ private _lodLevel;
25
27
  /** Shader language used */
26
28
  protected _shaderLanguage: ShaderLanguage;
27
29
  /**
28
30
  * Gets the shader language
29
31
  */
30
32
  get shaderLanguage(): ShaderLanguage;
33
+ /**
34
+ * Gets the effect wrapper used for the copy
35
+ */
36
+ get effectWrapper(): EffectWrapper;
37
+ /**
38
+ * Gets or sets the source texture
39
+ */
40
+ get source(): InternalTexture | ThinTexture;
41
+ set source(texture: InternalTexture | ThinTexture);
42
+ /**
43
+ * Gets or sets the LOD level to copy from the source texture
44
+ */
45
+ get lodLevel(): number;
46
+ set lodLevel(level: number);
31
47
  private _textureIsInternal;
32
48
  /**
33
49
  * Constructs a new instance of the class
@@ -48,9 +64,10 @@ export declare class CopyTextureToTexture {
48
64
  * @param source The source texture
49
65
  * @param destination The destination texture. If null, copy the source to the currently bound framebuffer
50
66
  * @param conversion The conversion mode that should be applied when copying
67
+ * @param lod The LOD level to copy from the source texture
51
68
  * @returns
52
69
  */
53
- copy(source: InternalTexture | ThinTexture, destination?: Nullable<RenderTargetWrapper | IRenderTargetTexture>, conversion?: ConversionMode): boolean;
70
+ copy(source: InternalTexture | ThinTexture, destination?: Nullable<RenderTargetWrapper | IRenderTargetTexture>, conversion?: ConversionMode, lod?: number): boolean;
54
71
  /**
55
72
  * Releases all the resources used by the class
56
73
  */
@@ -19,6 +19,30 @@ export class CopyTextureToTexture {
19
19
  get shaderLanguage() {
20
20
  return this._shaderLanguage;
21
21
  }
22
+ /**
23
+ * Gets the effect wrapper used for the copy
24
+ */
25
+ get effectWrapper() {
26
+ return this._effectWrapper;
27
+ }
28
+ /**
29
+ * Gets or sets the source texture
30
+ */
31
+ get source() {
32
+ return this._source;
33
+ }
34
+ set source(texture) {
35
+ this._source = texture;
36
+ }
37
+ /**
38
+ * Gets or sets the LOD level to copy from the source texture
39
+ */
40
+ get lodLevel() {
41
+ return this._lodLevel;
42
+ }
43
+ set lodLevel(level) {
44
+ this._lodLevel = level;
45
+ }
22
46
  _textureIsInternal(texture) {
23
47
  return texture.getInternalTexture === undefined;
24
48
  }
@@ -34,6 +58,8 @@ export class CopyTextureToTexture {
34
58
  this._shadersLoaded = false;
35
59
  this._engine = engine;
36
60
  this._isDepthTexture = isDepthTexture;
61
+ this._lodLevel = 0;
62
+ this._conversion = 0 /* ConversionMode.None */;
37
63
  this._renderer = new EffectRenderer(engine);
38
64
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
39
65
  this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);
@@ -60,7 +86,7 @@ export class CopyTextureToTexture {
60
86
  name: "CopyTextureToTexture",
61
87
  fragmentShader: "copyTextureToTexture",
62
88
  useShaderStore: true,
63
- uniformNames: ["conversion"],
89
+ uniformNames: ["conversion", "lodLevel"],
64
90
  samplerNames: ["textureSampler"],
65
91
  defines,
66
92
  shaderLanguage: this._shaderLanguage,
@@ -83,6 +109,7 @@ export class CopyTextureToTexture {
83
109
  this._effectWrapper.effect.setTexture("textureSampler", this._source);
84
110
  }
85
111
  this._effectWrapper.effect.setFloat("conversion", this._conversion);
112
+ this._effectWrapper.effect.setFloat("lodLevel", this._lodLevel);
86
113
  });
87
114
  }
88
115
  /**
@@ -97,14 +124,16 @@ export class CopyTextureToTexture {
97
124
  * @param source The source texture
98
125
  * @param destination The destination texture. If null, copy the source to the currently bound framebuffer
99
126
  * @param conversion The conversion mode that should be applied when copying
127
+ * @param lod The LOD level to copy from the source texture
100
128
  * @returns
101
129
  */
102
- copy(source, destination = null, conversion = 0 /* ConversionMode.None */) {
130
+ copy(source, destination = null, conversion = 0 /* ConversionMode.None */, lod = 0) {
103
131
  if (!this.isReady()) {
104
132
  return false;
105
133
  }
106
134
  this._source = source;
107
135
  this._conversion = conversion;
136
+ this._lodLevel = lod;
108
137
  const engineDepthFunc = this._engine.getDepthFunction();
109
138
  const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates
110
139
  this._renderer.render(this._effectWrapper, destination);
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK;QApBhF,2BAA2B;QACjB,oBAAe,+BAAuB;QA6BxC,mBAAc,GAAG,KAAK,CAAC;QAT3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5C,mEAAmE;QACnE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAGO,KAAK,CAAC,sBAAsB,CAAC,cAAuB,EAAE,YAAqB;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,MAAM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AI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAY7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,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AAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n private _lodLevel: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n /**\r\n * Gets or sets the LOD level to copy from the source texture\r\n */\r\n public get lodLevel(): number {\r\n return this._lodLevel;\r\n }\r\n\r\n public set lodLevel(level: number) {\r\n this._lodLevel = level;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n this._lodLevel = 0;\r\n this._conversion = ConversionMode.None;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\", \"lodLevel\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n this._effectWrapper.effect.setFloat(\"lodLevel\", this._lodLevel);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @param lod The LOD level to copy from the source texture\r\n * @returns\r\n */\r\n public copy(\r\n source: InternalTexture | ThinTexture,\r\n destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null,\r\n conversion = ConversionMode.None,\r\n lod = 0\r\n ): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n this._lodLevel = lod;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
@@ -77,11 +77,11 @@ export class BoxShapeBlock extends NodeParticleBlock {
77
77
  const randX = RandomRange(direction1.x, direction2.x);
78
78
  const randY = RandomRange(direction1.y, direction2.y);
79
79
  const randZ = RandomRange(direction1.z, direction2.z);
80
- if (state.isEmitterTransformNode) {
81
- Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
80
+ if (system.isLocal) {
81
+ particle.direction.copyFromFloats(randX, randY, randZ);
82
82
  }
83
83
  else {
84
- particle.direction.copyFromFloats(randX, randY, randZ);
84
+ Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
85
85
  }
86
86
  particle._initialDirection = particle.direction.clone();
87
87
  };
@@ -93,13 +93,13 @@ export class BoxShapeBlock extends NodeParticleBlock {
93
93
  const randX = RandomRange(minEmitBox.x, maxEmitBox.x);
94
94
  const randY = RandomRange(minEmitBox.y, maxEmitBox.y);
95
95
  const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);
96
- if (state.isEmitterTransformNode) {
97
- Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
98
- }
99
- else {
96
+ if (system.isLocal) {
100
97
  particle.position.copyFromFloats(randX, randY, randZ);
101
98
  particle.position.addInPlace(state.emitterPosition);
102
99
  }
100
+ else {
101
+ Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
102
+ }
103
103
  };
104
104
  this.output._storedValue = system;
105
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAA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AAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
1
+ {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,Y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BAAiB,CAAC,KAAK,CAAY,CAAC;YACvE,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAY,CAAC;YAEvE,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
@@ -39,6 +39,10 @@ export declare class CreateParticleBlock extends NodeParticleBlock {
39
39
  * Gets the angle input component
40
40
  */
41
41
  get angle(): NodeParticleConnectionPoint;
42
+ /**
43
+ * Gets the size component
44
+ */
45
+ get size(): NodeParticleConnectionPoint;
42
46
  /**
43
47
  * Gets the particle output component
44
48
  */