@babylonjs/core 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/Animations/animationGroup.d.ts +1 -1
  2. package/Animations/animationGroup.js +1 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Animations/runtimeAnimation.js +10 -3
  5. package/Animations/runtimeAnimation.js.map +1 -1
  6. package/Compute/computeEffect.d.ts +3 -4
  7. package/Compute/computeEffect.js +40 -33
  8. package/Compute/computeEffect.js.map +1 -1
  9. package/Compute/computeShader.d.ts +2 -2
  10. package/Compute/computeShader.js.map +1 -1
  11. package/Engines/Extensions/engine.computeShader.d.ts +27 -3
  12. package/Engines/Extensions/engine.computeShader.js +1 -1
  13. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  14. package/Engines/Extensions/engine.multiRender.js +1 -1
  15. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  16. package/Engines/Extensions/engine.renderTarget.js +12 -2
  17. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  18. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
  19. package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
  20. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  21. package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
  22. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  23. package/Engines/WebGPU/Extensions/engine.multiRender.js +1 -1
  24. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  25. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  27. package/Engines/WebGPU/webgpuClearQuad.d.ts +2 -2
  28. package/Engines/WebGPU/webgpuClearQuad.js +8 -3
  29. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  30. package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
  31. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  32. package/Engines/WebGPU/webgpuHardwareTexture.js +1 -0
  33. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  34. package/Engines/WebGPU/webgpuShaderProcessor.js +15 -0
  35. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  36. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
  37. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +10 -2
  38. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  39. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
  40. package/Engines/WebGPU/webgpuTextureManager.js +7 -7
  41. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  42. package/Engines/nativeEngine.d.ts +1 -0
  43. package/Engines/nativeEngine.js.map +1 -1
  44. package/Engines/nullEngine.d.ts +1 -0
  45. package/Engines/nullEngine.js.map +1 -1
  46. package/Engines/renderTargetWrapper.d.ts +14 -2
  47. package/Engines/renderTargetWrapper.js +23 -3
  48. package/Engines/renderTargetWrapper.js.map +1 -1
  49. package/Engines/thinEngine.d.ts +3 -7
  50. package/Engines/thinEngine.js +23 -9
  51. package/Engines/thinEngine.js.map +1 -1
  52. package/Engines/webgpuEngine.d.ts +2 -2
  53. package/Engines/webgpuEngine.js +19 -9
  54. package/Engines/webgpuEngine.js.map +1 -1
  55. package/Gizmos/axisScaleGizmo.js +6 -1
  56. package/Gizmos/axisScaleGizmo.js.map +1 -1
  57. package/Gizmos/boundingBoxGizmo.d.ts +2 -2
  58. package/Gizmos/boundingBoxGizmo.js +27 -17
  59. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  60. package/Gizmos/scaleGizmo.d.ts +6 -0
  61. package/Gizmos/scaleGizmo.js +10 -2
  62. package/Gizmos/scaleGizmo.js.map +1 -1
  63. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  64. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  65. package/Lights/Shadows/shadowGenerator.js +17 -2
  66. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  67. package/Materials/Node/Blocks/Dual/textureBlock.js +5 -0
  68. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  69. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -0
  70. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  71. package/Materials/Node/Blocks/addBlock.d.ts +2 -15
  72. package/Materials/Node/Blocks/addBlock.js +4 -32
  73. package/Materials/Node/Blocks/addBlock.js.map +1 -1
  74. package/Materials/Node/Blocks/baseMathBlock.d.ts +26 -0
  75. package/Materials/Node/Blocks/baseMathBlock.js +84 -0
  76. package/Materials/Node/Blocks/baseMathBlock.js.map +1 -0
  77. package/Materials/Node/Blocks/divideBlock.d.ts +2 -15
  78. package/Materials/Node/Blocks/divideBlock.js +4 -32
  79. package/Materials/Node/Blocks/divideBlock.js.map +1 -1
  80. package/Materials/Node/Blocks/multiplyBlock.d.ts +2 -15
  81. package/Materials/Node/Blocks/multiplyBlock.js +4 -32
  82. package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
  83. package/Materials/Node/Blocks/subtractBlock.d.ts +2 -15
  84. package/Materials/Node/Blocks/subtractBlock.js +4 -32
  85. package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
  86. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +4 -0
  87. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +7 -0
  88. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  89. package/Materials/PBR/pbrBaseMaterial.js +1 -5
  90. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  91. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
  92. package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
  93. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  94. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
  95. package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
  96. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  97. package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
  98. package/Materials/PBR/pbrSheenConfiguration.js +3 -12
  99. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  100. package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
  101. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  102. package/Materials/Textures/baseTexture.d.ts +0 -6
  103. package/Materials/Textures/baseTexture.js +0 -8
  104. package/Materials/Textures/baseTexture.js.map +1 -1
  105. package/Materials/Textures/renderTargetTexture.d.ts +8 -24
  106. package/Materials/Textures/renderTargetTexture.js +13 -8
  107. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  108. package/Materials/Textures/texture.d.ts +5 -8
  109. package/Materials/Textures/texture.js +10 -20
  110. package/Materials/Textures/texture.js.map +1 -1
  111. package/Materials/Textures/textureCreationOptions.d.ts +1 -0
  112. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  113. package/Materials/Textures/thinTexture.js +1 -1
  114. package/Materials/Textures/thinTexture.js.map +1 -1
  115. package/Materials/effect.d.ts +3 -3
  116. package/Materials/effect.js.map +1 -1
  117. package/Materials/shaderMaterial.d.ts +3 -3
  118. package/Materials/shaderMaterial.js.map +1 -1
  119. package/Maths/math.vector.d.ts +12 -0
  120. package/Maths/math.vector.js +17 -2
  121. package/Maths/math.vector.js.map +1 -1
  122. package/Maths/tensor.d.ts +13 -11
  123. package/Maths/tensor.js.map +1 -1
  124. package/Meshes/Builders/greasedLineBuilder.js +14 -0
  125. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  126. package/Meshes/Builders/ribbonBuilder.js +32 -28
  127. package/Meshes/Builders/ribbonBuilder.js.map +1 -1
  128. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +18 -6
  129. package/Meshes/GreasedLine/greasedLineBaseMesh.js +17 -1
  130. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  131. package/Meshes/GreasedLine/greasedLineMesh.d.ts +0 -2
  132. package/Meshes/GreasedLine/greasedLineMesh.js +84 -77
  133. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  134. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +19 -4
  135. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  136. package/Meshes/Node/Blocks/mathBlock.d.ts +6 -0
  137. package/Meshes/Node/Blocks/mathBlock.js +95 -23
  138. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  139. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +4 -0
  140. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +7 -0
  141. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  142. package/Misc/greasedLineTools.d.ts +6 -0
  143. package/Misc/greasedLineTools.js +21 -0
  144. package/Misc/greasedLineTools.js.map +1 -1
  145. package/Rendering/depthPeelingRenderer.js +1 -1
  146. package/Rendering/depthPeelingRenderer.js.map +1 -1
  147. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  148. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  149. package/Rendering/reflectiveShadowMap.js +1 -1
  150. package/Rendering/reflectiveShadowMap.js.map +1 -1
  151. package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
  152. package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
  153. package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
  154. package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
  155. package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
  156. package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
  157. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
  158. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  159. package/Shaders/ShadersInclude/pbrDebug.js +2 -0
  160. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  161. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
  162. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  163. package/Shaders/greasedLine.vertex.js +3 -3
  164. package/Shaders/greasedLine.vertex.js.map +1 -1
  165. package/Shaders/pbr.fragment.js +4 -4
  166. package/Shaders/pbr.fragment.js.map +1 -1
  167. package/ShadersWGSL/clearQuad.fragment.js +11 -0
  168. package/ShadersWGSL/clearQuad.fragment.js.map +1 -0
  169. package/ShadersWGSL/clearQuad.vertex.js +22 -0
  170. package/ShadersWGSL/clearQuad.vertex.js.map +1 -0
  171. package/XR/features/WebXRHandTracking.d.ts +5 -0
  172. package/XR/features/WebXRHandTracking.js +6 -0
  173. package/XR/features/WebXRHandTracking.js.map +1 -1
  174. package/node.js +1 -6
  175. package/node.js.map +1 -1
  176. package/package.json +1 -1
  177. package/Shaders/clearQuad.fragment.js +0 -10
  178. package/Shaders/clearQuad.fragment.js.map +0 -1
  179. package/Shaders/clearQuad.vertex.js +0 -19
  180. package/Shaders/clearQuad.vertex.js.map +0 -1
  181. /package/{Shaders → ShadersWGSL}/clearQuad.fragment.d.ts +0 -0
  182. /package/{Shaders → ShadersWGSL}/clearQuad.vertex.d.ts +0 -0
@@ -39,15 +39,21 @@ export class MathBlock extends NodeGeometryBlock {
39
39
  this.registerInput("left", NodeGeometryBlockConnectionPointTypes.AutoDetect);
40
40
  this.registerInput("right", NodeGeometryBlockConnectionPointTypes.AutoDetect);
41
41
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
42
- this._outputs[0]._typeConnectionSource = this._inputs[0];
43
- this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
44
- this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);
45
- this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);
46
- this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
47
- this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);
48
- this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);
49
- this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
42
+ this.output._typeConnectionSource = this.left;
43
+ const excludedConnectionPointTypes = [
44
+ NodeGeometryBlockConnectionPointTypes.Matrix,
45
+ NodeGeometryBlockConnectionPointTypes.Geometry,
46
+ NodeGeometryBlockConnectionPointTypes.Texture,
47
+ ];
48
+ this.left.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);
49
+ this.right.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);
50
50
  this._linkConnectionTypes(0, 1);
51
+ this._connectionObservers = [
52
+ this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),
53
+ this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),
54
+ this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),
55
+ this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),
56
+ ];
51
57
  }
52
58
  /**
53
59
  * Gets the current class name
@@ -83,14 +89,22 @@ export class MathBlock extends NodeGeometryBlock {
83
89
  this.output._storedValue = null;
84
90
  return;
85
91
  }
86
- const isFloat = left.type === NodeGeometryBlockConnectionPointTypes.Float || left.type === NodeGeometryBlockConnectionPointTypes.Int;
92
+ const leftIsScalar = left.type === NodeGeometryBlockConnectionPointTypes.Float || left.type === NodeGeometryBlockConnectionPointTypes.Int;
93
+ const rightIsScalar = right.type === NodeGeometryBlockConnectionPointTypes.Float || right.type === NodeGeometryBlockConnectionPointTypes.Int;
94
+ // If both input types are scalars, then this is a scalar operation.
95
+ const isScalar = leftIsScalar && rightIsScalar;
87
96
  switch (this.operation) {
88
97
  case MathBlockOperations.Add: {
89
- if (isFloat) {
98
+ if (isScalar) {
90
99
  func = (state) => {
91
100
  return left.getConnectedValue(state) + right.getConnectedValue(state);
92
101
  };
93
102
  }
103
+ else if (leftIsScalar) {
104
+ func = (state) => {
105
+ return state.adapt(left, right.type).add(right.getConnectedValue(state));
106
+ };
107
+ }
94
108
  else {
95
109
  func = (state) => {
96
110
  return left.getConnectedValue(state).add(state.adapt(right, left.type));
@@ -99,11 +113,16 @@ export class MathBlock extends NodeGeometryBlock {
99
113
  break;
100
114
  }
101
115
  case MathBlockOperations.Subtract: {
102
- if (isFloat) {
116
+ if (isScalar) {
103
117
  func = (state) => {
104
118
  return left.getConnectedValue(state) - right.getConnectedValue(state);
105
119
  };
106
120
  }
121
+ else if (leftIsScalar) {
122
+ func = (state) => {
123
+ return state.adapt(left, right.type).subtract(right.getConnectedValue(state));
124
+ };
125
+ }
107
126
  else {
108
127
  func = (state) => {
109
128
  return left.getConnectedValue(state).subtract(state.adapt(right, left.type));
@@ -112,11 +131,16 @@ export class MathBlock extends NodeGeometryBlock {
112
131
  break;
113
132
  }
114
133
  case MathBlockOperations.Multiply: {
115
- if (isFloat) {
134
+ if (isScalar) {
116
135
  func = (state) => {
117
136
  return left.getConnectedValue(state) * right.getConnectedValue(state);
118
137
  };
119
138
  }
139
+ else if (leftIsScalar) {
140
+ func = (state) => {
141
+ return state.adapt(left, right.type).multiply(right.getConnectedValue(state));
142
+ };
143
+ }
120
144
  else {
121
145
  func = (state) => {
122
146
  return left.getConnectedValue(state).multiply(state.adapt(right, left.type));
@@ -125,11 +149,16 @@ export class MathBlock extends NodeGeometryBlock {
125
149
  break;
126
150
  }
127
151
  case MathBlockOperations.Divide: {
128
- if (isFloat) {
152
+ if (isScalar) {
129
153
  func = (state) => {
130
154
  return left.getConnectedValue(state) / right.getConnectedValue(state);
131
155
  };
132
156
  }
157
+ else if (leftIsScalar) {
158
+ func = (state) => {
159
+ return state.adapt(left, right.type).divide(right.getConnectedValue(state));
160
+ };
161
+ }
133
162
  else {
134
163
  func = (state) => {
135
164
  return left.getConnectedValue(state).divide(state.adapt(right, left.type));
@@ -138,28 +167,29 @@ export class MathBlock extends NodeGeometryBlock {
138
167
  break;
139
168
  }
140
169
  case MathBlockOperations.Min: {
141
- if (isFloat) {
170
+ if (isScalar) {
142
171
  func = (state) => {
143
172
  return Math.min(left.getConnectedValue(state), right.getConnectedValue(state));
144
173
  };
145
174
  }
146
175
  else {
147
- switch (left.type) {
176
+ const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];
177
+ switch (vector.type) {
148
178
  case NodeGeometryBlockConnectionPointTypes.Vector2: {
149
179
  func = (state) => {
150
- return Vector2.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));
180
+ return Vector2.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
151
181
  };
152
182
  break;
153
183
  }
154
184
  case NodeGeometryBlockConnectionPointTypes.Vector3: {
155
185
  func = (state) => {
156
- return Vector3.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));
186
+ return Vector3.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
157
187
  };
158
188
  break;
159
189
  }
160
190
  case NodeGeometryBlockConnectionPointTypes.Vector4: {
161
191
  func = (state) => {
162
- return Vector4.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));
192
+ return Vector4.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
163
193
  };
164
194
  break;
165
195
  }
@@ -168,28 +198,29 @@ export class MathBlock extends NodeGeometryBlock {
168
198
  break;
169
199
  }
170
200
  case MathBlockOperations.Max: {
171
- if (isFloat) {
201
+ if (isScalar) {
172
202
  func = (state) => {
173
203
  return Math.max(left.getConnectedValue(state), right.getConnectedValue(state));
174
204
  };
175
205
  }
176
206
  else {
177
- switch (left.type) {
207
+ const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];
208
+ switch (vector.type) {
178
209
  case NodeGeometryBlockConnectionPointTypes.Vector2: {
179
210
  func = (state) => {
180
- return Vector2.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));
211
+ return Vector2.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
181
212
  };
182
213
  break;
183
214
  }
184
215
  case NodeGeometryBlockConnectionPointTypes.Vector3: {
185
216
  func = (state) => {
186
- return Vector3.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));
217
+ return Vector3.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
187
218
  };
188
219
  break;
189
220
  }
190
221
  case NodeGeometryBlockConnectionPointTypes.Vector4: {
191
222
  func = (state) => {
192
- return Vector4.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));
223
+ return Vector4.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));
193
224
  };
194
225
  break;
195
226
  }
@@ -209,6 +240,47 @@ export class MathBlock extends NodeGeometryBlock {
209
240
  const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.operation = BABYLON.MathBlockOperations.${MathBlockOperations[this.operation]};\n`;
210
241
  return codeString;
211
242
  }
243
+ _updateInputOutputTypes() {
244
+ // First update the output type with the initial assumption that we'll base it on the left input.
245
+ this.output._typeConnectionSource = this.left;
246
+ if (this.left.isConnected && this.right.isConnected) {
247
+ // Both inputs are connected, so we need to determine the output type based on the input types.
248
+ if (this.left.type === NodeGeometryBlockConnectionPointTypes.Int ||
249
+ (this.left.type === NodeGeometryBlockConnectionPointTypes.Float && this.right.type !== NodeGeometryBlockConnectionPointTypes.Int)) {
250
+ this.output._typeConnectionSource = this.right;
251
+ }
252
+ }
253
+ else if (this.left.isConnected !== this.right.isConnected) {
254
+ // Only one input is connected, so we need to determine the output type based on the connected input.
255
+ this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;
256
+ }
257
+ // Next update the accepted connection point types for the inputs based on the current input connection state.
258
+ if (this.left.isConnected || this.right.isConnected) {
259
+ for (const [first, second] of [
260
+ [this.left, this.right],
261
+ [this.right, this.left],
262
+ ]) {
263
+ // Always allow Ints and Floats.
264
+ first.acceptedConnectionPointTypes = [NodeGeometryBlockConnectionPointTypes.Int, NodeGeometryBlockConnectionPointTypes.Float];
265
+ if (second.isConnected) {
266
+ // The same types as the connected input are always allowed.
267
+ first.acceptedConnectionPointTypes.push(second.type);
268
+ // If the other input is a scalar, then we also allow Vector types.
269
+ if (second.type === NodeGeometryBlockConnectionPointTypes.Int || second.type === NodeGeometryBlockConnectionPointTypes.Float) {
270
+ first.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Vector2, NodeGeometryBlockConnectionPointTypes.Vector3, NodeGeometryBlockConnectionPointTypes.Vector4);
271
+ }
272
+ }
273
+ }
274
+ }
275
+ }
276
+ /**
277
+ * Release resources
278
+ */
279
+ dispose() {
280
+ super.dispose();
281
+ this._connectionObservers.forEach((observer) => observer.remove());
282
+ this._connectionObservers.length = 0;
283
+ }
212
284
  /**
213
285
  * Serializes this block in a JSON representation
214
286
  * @returns the serialized block object
@@ -1 +1 @@
1
- {"version":3,"file":"mathBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/mathBlock.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,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACnE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEnG;;GAEG;AACH,MAAM,CAAN,IAAY,mBAaX;AAbD,WAAY,mBAAmB;IAC3B,UAAU;IACV,2DAAG,CAAA;IACH,eAAe;IACf,qEAAQ,CAAA;IACR,eAAe;IACf,qEAAQ,CAAA;IACR,aAAa;IACb,iEAAM,CAAA;IACN,UAAU;IACV,2DAAG,CAAA;IACH,UAAU;IACV,2DAAG,CAAA;AACP,CAAC,EAbW,mBAAmB,K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OAAO,EAAE;YACL,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE;YACtD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;SACnD;KACJ,CAAC;4CACyC;AAgN/C,aAAa,CAAC,mBAAmB,EAAE,SAAS,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 { Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Operations supported by the Math block\r\n */\r\nexport enum MathBlockOperations {\r\n /** Add */\r\n Add,\r\n /** Subtract */\r\n Subtract,\r\n /** Multiply */\r\n Multiply,\r\n /** Divide */\r\n Divide,\r\n /** Max */\r\n Max,\r\n /** Min */\r\n Min,\r\n}\r\n\r\n/**\r\n * Block used to apply math functions\r\n */\r\nexport class MathBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Add\", value: MathBlockOperations.Add },\r\n { label: \"Subtract\", value: MathBlockOperations.Subtract },\r\n { label: \"Multiply\", value: MathBlockOperations.Multiply },\r\n { label: \"Divide\", value: MathBlockOperations.Divide },\r\n { label: \"Max\", value: MathBlockOperations.Max },\r\n { label: \"Min\", value: MathBlockOperations.Min },\r\n ],\r\n })\r\n public operation = MathBlockOperations.Add;\r\n\r\n /**\r\n * Create a new MathBlock\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(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\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 this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\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 getClassName() {\r\n return \"MathBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): 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 protected _buildBlock() {\r\n let func: (state: NodeGeometryBuildState) => any;\r\n const left = this.left;\r\n const right = this.right;\r\n\r\n if (!left.isConnected || !right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const isFloat = left.type === NodeGeometryBlockConnectionPointTypes.Float || left.type === NodeGeometryBlockConnectionPointTypes.Int;\r\n\r\n switch (this.operation) {\r\n case MathBlockOperations.Add: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) + right.getConnectedValue(state);\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).add(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Subtract: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) - right.getConnectedValue(state);\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).subtract(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Multiply: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) * right.getConnectedValue(state);\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).multiply(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Divide: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) / right.getConnectedValue(state);\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).divide(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Min: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return Math.min(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n switch (left.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n return Vector4.Minimize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Max: {\r\n if (isFloat) {\r\n func = (state) => {\r\n return Math.max(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n switch (left.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n return Vector4.Maximize(left.getConnectedValue(state), state.adapt(right, left.type));\r\n };\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n if (left.type === NodeGeometryBlockConnectionPointTypes.Int) {\r\n return func(state) | 0;\r\n }\r\n return func(state);\r\n };\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.operation = BABYLON.MathBlockOperations.${MathBlockOperations[this.operation]};\\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 serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MathBlock\", MathBlock);\r\n"]}
1
+ {"version":3,"file":"mathBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/mathBlock.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,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACnE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGnG;;GAEG;AACH,MAAM,CAAN,IAAY,mBAaX;AAbD,WAAY,mBAAmB;IAC3B,UAAU;IACV,2DAAG,CAAA;IACH,eAAe;IACf,qEAAQ,CAAA;IACR,eAAe;IACf,qEAAQ,CAAA;IACR,aAAa;IACb,iEAAM,CAAA;IACN,UAAU;IACV,2DAAG,CAAA;IACH,UAAU;IACV,2DAAG,CAAA;AACP,CAAC,EAbW,mBAAmB,KAAnB,mBAAmB,QAa9B;AAED;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,iBAAiB;IAmB5C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAvBhB;;WAEG;QAYI,cAAS,GAAG,mBAAmB,CAAC,GAAG,CAAC;QAWvC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAA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,EAAE,CAAC;QAE9C,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAE/C,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC;IACnD,CAAC;CACJ;AAtSU;IAXN,sBAAsB,CAAC,WAAW,EAAE,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE;QAC1E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE;YACtD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;SACnD;KACJ,CAAC;4CACyC;AAwS/C,aAAa,CAAC,mBAAmB,EAAE,SAAS,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 { Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\n\r\n/**\r\n * Operations supported by the Math block\r\n */\r\nexport enum MathBlockOperations {\r\n /** Add */\r\n Add,\r\n /** Subtract */\r\n Subtract,\r\n /** Multiply */\r\n Multiply,\r\n /** Divide */\r\n Divide,\r\n /** Max */\r\n Max,\r\n /** Min */\r\n Min,\r\n}\r\n\r\n/**\r\n * Block used to apply math functions\r\n */\r\nexport class MathBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Add\", value: MathBlockOperations.Add },\r\n { label: \"Subtract\", value: MathBlockOperations.Subtract },\r\n { label: \"Multiply\", value: MathBlockOperations.Multiply },\r\n { label: \"Divide\", value: MathBlockOperations.Divide },\r\n { label: \"Max\", value: MathBlockOperations.Max },\r\n { label: \"Min\", value: MathBlockOperations.Min },\r\n ],\r\n })\r\n public operation = MathBlockOperations.Add;\r\n\r\n private readonly _connectionObservers: Observer<NodeGeometryConnectionPoint>[];\r\n\r\n /**\r\n * Create a new MathBlock\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(\"left\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = this.left;\r\n\r\n const excludedConnectionPointTypes = [\r\n NodeGeometryBlockConnectionPointTypes.Matrix,\r\n NodeGeometryBlockConnectionPointTypes.Geometry,\r\n NodeGeometryBlockConnectionPointTypes.Texture,\r\n ] as const;\r\n\r\n this.left.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n this.right.excludedConnectionPointTypes.push(...excludedConnectionPointTypes);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._connectionObservers = [\r\n this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n ];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"MathBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): 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 protected _buildBlock() {\r\n let func: (state: NodeGeometryBuildState) => any;\r\n const left = this.left;\r\n const right = this.right;\r\n\r\n if (!left.isConnected || !right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const leftIsScalar = left.type === NodeGeometryBlockConnectionPointTypes.Float || left.type === NodeGeometryBlockConnectionPointTypes.Int;\r\n const rightIsScalar = right.type === NodeGeometryBlockConnectionPointTypes.Float || right.type === NodeGeometryBlockConnectionPointTypes.Int;\r\n\r\n // If both input types are scalars, then this is a scalar operation.\r\n const isScalar = leftIsScalar && rightIsScalar;\r\n\r\n switch (this.operation) {\r\n case MathBlockOperations.Add: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) + right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).add(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).add(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Subtract: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) - right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).subtract(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).subtract(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Multiply: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) * right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).multiply(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).multiply(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Divide: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return left.getConnectedValue(state) / right.getConnectedValue(state);\r\n };\r\n } else if (leftIsScalar) {\r\n func = (state) => {\r\n return state.adapt(left, right.type).divide(right.getConnectedValue(state));\r\n };\r\n } else {\r\n func = (state) => {\r\n return left.getConnectedValue(state).divide(state.adapt(right, left.type));\r\n };\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Min: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.min(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n return Vector4.Minimize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case MathBlockOperations.Max: {\r\n if (isScalar) {\r\n func = (state) => {\r\n return Math.max(left.getConnectedValue(state), right.getConnectedValue(state));\r\n };\r\n } else {\r\n const [vector, scalar] = leftIsScalar ? [right, left] : [left, right];\r\n\r\n switch (vector.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n return Vector2.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n return Vector3.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n return Vector4.Maximize(vector.getConnectedValue(state), state.adapt(scalar, vector.type));\r\n };\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n if (left.type === NodeGeometryBlockConnectionPointTypes.Int) {\r\n return func(state) | 0;\r\n }\r\n return func(state);\r\n };\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.operation = BABYLON.MathBlockOperations.${MathBlockOperations[this.operation]};\\n`;\r\n return codeString;\r\n }\r\n\r\n private _updateInputOutputTypes() {\r\n // First update the output type with the initial assumption that we'll base it on the left input.\r\n this.output._typeConnectionSource = this.left;\r\n\r\n if (this.left.isConnected && this.right.isConnected) {\r\n // Both inputs are connected, so we need to determine the output type based on the input types.\r\n if (\r\n this.left.type === NodeGeometryBlockConnectionPointTypes.Int ||\r\n (this.left.type === NodeGeometryBlockConnectionPointTypes.Float && this.right.type !== NodeGeometryBlockConnectionPointTypes.Int)\r\n ) {\r\n this.output._typeConnectionSource = this.right;\r\n }\r\n } else if (this.left.isConnected !== this.right.isConnected) {\r\n // Only one input is connected, so we need to determine the output type based on the connected input.\r\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\r\n }\r\n\r\n // Next update the accepted connection point types for the inputs based on the current input connection state.\r\n if (this.left.isConnected || this.right.isConnected) {\r\n for (const [first, second] of [\r\n [this.left, this.right],\r\n [this.right, this.left],\r\n ]) {\r\n // Always allow Ints and Floats.\r\n first.acceptedConnectionPointTypes = [NodeGeometryBlockConnectionPointTypes.Int, NodeGeometryBlockConnectionPointTypes.Float];\r\n\r\n if (second.isConnected) {\r\n // The same types as the connected input are always allowed.\r\n first.acceptedConnectionPointTypes.push(second.type);\r\n\r\n // If the other input is a scalar, then we also allow Vector types.\r\n if (second.type === NodeGeometryBlockConnectionPointTypes.Int || second.type === NodeGeometryBlockConnectionPointTypes.Float) {\r\n first.acceptedConnectionPointTypes.push(\r\n NodeGeometryBlockConnectionPointTypes.Vector2,\r\n NodeGeometryBlockConnectionPointTypes.Vector3,\r\n NodeGeometryBlockConnectionPointTypes.Vector4\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n this._connectionObservers.forEach((observer) => observer.remove());\r\n this._connectionObservers.length = 0;\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 serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MathBlock\", MathBlock);\r\n"]}
@@ -60,6 +60,10 @@ export declare class NodeGeometryConnectionPoint {
60
60
  * Observable triggered when this point is connected
61
61
  */
62
62
  onConnectionObservable: Observable<NodeGeometryConnectionPoint>;
63
+ /**
64
+ * Observable triggered when this point is disconnected
65
+ */
66
+ onDisconnectionObservable: Observable<NodeGeometryConnectionPoint>;
63
67
  /**
64
68
  * Gets or sets a boolean indicating that this connection point is exposed on a frame
65
69
  */
@@ -176,6 +176,10 @@ export class NodeGeometryConnectionPoint {
176
176
  * Observable triggered when this point is connected
177
177
  */
178
178
  this.onConnectionObservable = new Observable();
179
+ /**
180
+ * Observable triggered when this point is disconnected
181
+ */
182
+ this.onDisconnectionObservable = new Observable();
179
183
  /**
180
184
  * Gets or sets a boolean indicating that this connection point is exposed on a frame
181
185
  */
@@ -285,6 +289,8 @@ export class NodeGeometryConnectionPoint {
285
289
  }
286
290
  this._endpoints.splice(index, 1);
287
291
  endpoint._connectedPoint = null;
292
+ this.onDisconnectionObservable.notifyObservers(endpoint);
293
+ endpoint.onDisconnectionObservable.notifyObservers(this);
288
294
  return this;
289
295
  }
290
296
  /**
@@ -331,6 +337,7 @@ export class NodeGeometryConnectionPoint {
331
337
  */
332
338
  dispose() {
333
339
  this.onConnectionObservable.clear();
340
+ this.onDisconnectionObservable.clear();
334
341
  }
335
342
  }
336
343
  //# sourceMappingURL=nodeGeometryBlockConnectionPoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeGeometryBlockConnectionPoint.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometryBlockConnectionPoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AAIjG;;GAEG;AACH,MAAM,CAAN,IAAY,8CAOX;AAPD,WAAY,8CAA8C;IACtD,6BAA6B;IAC7B,+HAAU,CAAA;IACV,qDAAqD;IACrD,2IAAgB,CAAA;IAChB,sEAAsE;IACtE,uIAAc,CAAA;AAClB,CAAC,EAPW,8CAA8C,KAA9C,8CAA8C,QAOzD;AAED;;GAEG;AACH,MAAM,C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,CAAC;YAC1C,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC5E,mBAAmB,CAAC,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;SACvE;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { NodeGeometryBlock } from \"./nodeGeometryBlock\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { GeometryInputBlock } from \"./Blocks/geometryInputBlock\";\r\nimport type { NodeGeometryBuildState } from \"./nodeGeometryBuildState\";\r\n\r\n/**\r\n * Enum used to define the compatibility state between two connection points\r\n */\r\nexport enum NodeGeometryConnectionPointCompatibilityStates {\r\n /** Points are compatibles */\r\n Compatible,\r\n /** Points are incompatible because of their types */\r\n TypeIncompatible,\r\n /** Points are incompatible because they are in the same hierarchy **/\r\n HierarchyIssue,\r\n}\r\n\r\n/**\r\n * Defines the direction of a connection point\r\n */\r\nexport enum NodeGeometryConnectionPointDirection {\r\n /** Input */\r\n Input,\r\n /** Output */\r\n Output,\r\n}\r\n\r\n/**\r\n * Defines a connection point for a block\r\n */\r\nexport class NodeGeometryConnectionPoint {\r\n /** @internal */\r\n public _ownerBlock: NodeGeometryBlock;\r\n /** @internal */\r\n public _connectedPoint: Nullable<NodeGeometryConnectionPoint> = null;\r\n /** @internal */\r\n public _storedValue: any = null;\r\n /** @internal */\r\n public _storedFunction: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n\r\n /** @internal */\r\n public _acceptedConnectionPointType: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n private _endpoints = new Array<NodeGeometryConnectionPoint>();\r\n private _direction: NodeGeometryConnectionPointDirection;\r\n private _type = NodeGeometryBlockConnectionPointTypes.Geometry;\r\n\r\n /** @internal */\r\n public _linkedConnectionSource: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n /** @internal */\r\n public _typeConnectionSource: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n /** @internal */\r\n public _defaultConnectionPointType: Nullable<NodeGeometryBlockConnectionPointTypes> = null;\r\n\r\n /** Gets the direction of the point */\r\n public get direction() {\r\n return this._direction;\r\n }\r\n\r\n /**\r\n * Gets or sets the additional types supported by this connection point\r\n */\r\n public acceptedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[] = [];\r\n\r\n /**\r\n * Gets or sets the additional types excluded by this connection point\r\n */\r\n public excludedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[] = [];\r\n\r\n /**\r\n * Observable triggered when this point is connected\r\n */\r\n public onConnectionObservable = new Observable<NodeGeometryConnectionPoint>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this connection point is exposed on a frame\r\n */\r\n public isExposedOnFrame: boolean = false;\r\n\r\n /**\r\n * Gets or sets number indicating the position that the port is exposed to on a frame\r\n */\r\n public exposedPortPosition: number = -1;\r\n\r\n /**\r\n * Gets the default value used for this point at creation time\r\n */\r\n public defaultValue: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the default value used for this point if nothing is connected\r\n */\r\n public value: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the min value accepted for this point if nothing is connected\r\n */\r\n public valueMin: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the max value accepted for this point if nothing is connected\r\n */\r\n public valueMax: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the connection point type (default is float)\r\n */\r\n public get type(): NodeGeometryBlockConnectionPointTypes {\r\n if (this._type === NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n if (this._ownerBlock.isInput) {\r\n return (this._ownerBlock as GeometryInputBlock).type;\r\n }\r\n\r\n if (this._connectedPoint) {\r\n return this._connectedPoint.type;\r\n }\r\n\r\n if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) {\r\n return this._linkedConnectionSource.type;\r\n }\r\n }\r\n\r\n if (this._type === NodeGeometryBlockConnectionPointTypes.BasedOnInput) {\r\n if (this._typeConnectionSource) {\r\n if (!this._typeConnectionSource.isConnected && this._defaultConnectionPointType) {\r\n return this._defaultConnectionPointType;\r\n }\r\n return this._typeConnectionSource.type;\r\n } else if (this._defaultConnectionPointType) {\r\n return this._defaultConnectionPointType;\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n public set type(value: NodeGeometryBlockConnectionPointTypes) {\r\n this._type = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the connection point name\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Gets or sets the connection point display name\r\n */\r\n public displayName: string;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this connection point can be omitted\r\n */\r\n public isOptional: boolean;\r\n\r\n /**\r\n * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock\r\n */\r\n public get isConnected(): boolean {\r\n return this.connectedPoint !== null || this.hasEndpoints;\r\n }\r\n\r\n /** Get the other side of the connection (if any) */\r\n public get connectedPoint(): Nullable<NodeGeometryConnectionPoint> {\r\n return this._connectedPoint;\r\n }\r\n\r\n /** Get the block that owns this connection point */\r\n public get ownerBlock(): NodeGeometryBlock {\r\n return this._ownerBlock;\r\n }\r\n\r\n /** Get the block connected on the other side of this connection (if any) */\r\n public get sourceBlock(): Nullable<NodeGeometryBlock> {\r\n if (!this._connectedPoint) {\r\n return null;\r\n }\r\n\r\n return this._connectedPoint.ownerBlock;\r\n }\r\n\r\n /** Get the block connected on the endpoints of this connection (if any) */\r\n public get connectedBlocks(): Array<NodeGeometryBlock> {\r\n if (this._endpoints.length === 0) {\r\n return [];\r\n }\r\n\r\n return this._endpoints.map((e) => e.ownerBlock);\r\n }\r\n\r\n /** Gets the list of connected endpoints */\r\n public get endpoints() {\r\n return this._endpoints;\r\n }\r\n\r\n /** Gets a boolean indicating if that output point is connected to at least one input */\r\n public get hasEndpoints(): boolean {\r\n return this._endpoints && this._endpoints.length > 0;\r\n }\r\n\r\n /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */\r\n public get innerType() {\r\n if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) {\r\n return this.type;\r\n }\r\n return this._type;\r\n }\r\n\r\n /** @internal */\r\n public _callCount = 0;\r\n\r\n /** @internal */\r\n public _executionCount = 0;\r\n\r\n /** @internal */\r\n public _resetCounters() {\r\n this._callCount = 0;\r\n this._executionCount = 0;\r\n }\r\n\r\n /**\r\n * Gets the number of times this point was called\r\n */\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n /**\r\n * Gets the number of times this point was executed\r\n */\r\n public get executionCount() {\r\n return this._executionCount;\r\n }\r\n\r\n /**\r\n * Gets the value represented by this connection point\r\n * @param state current evaluation state\r\n * @returns the connected value or the value if nothing is connected\r\n */\r\n public getConnectedValue(state: NodeGeometryBuildState) {\r\n if (this.isConnected) {\r\n if (this._connectedPoint?._storedFunction) {\r\n this._connectedPoint!._callCount++;\r\n this._connectedPoint!._executionCount++;\r\n return this._connectedPoint!._storedFunction(state);\r\n }\r\n this._connectedPoint!._callCount++;\r\n this._connectedPoint!._executionCount = 1;\r\n return this._connectedPoint!._storedValue;\r\n }\r\n this._callCount++;\r\n this._executionCount = 1;\r\n return this.value;\r\n }\r\n\r\n /**\r\n * Creates a new connection point\r\n * @param name defines the connection point name\r\n * @param ownerBlock defines the block hosting this connection point\r\n * @param direction defines the direction of the connection point\r\n */\r\n public constructor(name: string, ownerBlock: NodeGeometryBlock, direction: NodeGeometryConnectionPointDirection) {\r\n this._ownerBlock = ownerBlock;\r\n this.name = name;\r\n this._direction = direction;\r\n }\r\n\r\n /**\r\n * Gets the current class name e.g. \"NodeMaterialConnectionPoint\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeGeometryConnectionPoint\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the current point can be connected to another point\r\n * @param connectionPoint defines the other connection point\r\n * @returns a boolean\r\n */\r\n public canConnectTo(connectionPoint: NodeGeometryConnectionPoint) {\r\n return this.checkCompatibilityState(connectionPoint) === NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n }\r\n\r\n /**\r\n * Gets a number indicating if the current point can be connected to another point\r\n * @param connectionPoint defines the other connection point\r\n * @returns a number defining the compatibility state\r\n */\r\n public checkCompatibilityState(connectionPoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPointCompatibilityStates {\r\n const ownerBlock = this._ownerBlock;\r\n const otherBlock = connectionPoint.ownerBlock;\r\n\r\n if (this.type !== connectionPoint.type && connectionPoint.innerType !== NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n // Accepted types\r\n if (connectionPoint.acceptedConnectionPointTypes && connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1) {\r\n return NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n } else {\r\n return NodeGeometryConnectionPointCompatibilityStates.TypeIncompatible;\r\n }\r\n }\r\n\r\n // Excluded\r\n if (connectionPoint.excludedConnectionPointTypes && connectionPoint.excludedConnectionPointTypes.indexOf(this.type) !== -1) {\r\n return NodeGeometryConnectionPointCompatibilityStates.TypeIncompatible;\r\n }\r\n\r\n // Check hierarchy\r\n let targetBlock = otherBlock;\r\n let sourceBlock = ownerBlock;\r\n if (this.direction === NodeGeometryConnectionPointDirection.Input) {\r\n targetBlock = ownerBlock;\r\n sourceBlock = otherBlock;\r\n }\r\n\r\n if (targetBlock.isAnAncestorOf(sourceBlock)) {\r\n return NodeGeometryConnectionPointCompatibilityStates.HierarchyIssue;\r\n }\r\n\r\n return NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n }\r\n\r\n /**\r\n * Connect this point to another connection point\r\n * @param connectionPoint defines the other connection point\r\n * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)\r\n * @returns the current connection point\r\n */\r\n public connectTo(connectionPoint: NodeGeometryConnectionPoint, ignoreConstraints = false): NodeGeometryConnectionPoint {\r\n if (!ignoreConstraints && !this.canConnectTo(connectionPoint)) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Cannot connect these two connectors.\";\r\n }\r\n\r\n this._endpoints.push(connectionPoint);\r\n connectionPoint._connectedPoint = this;\r\n\r\n this.onConnectionObservable.notifyObservers(connectionPoint);\r\n connectionPoint.onConnectionObservable.notifyObservers(this);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Disconnect this point from one of his endpoint\r\n * @param endpoint defines the other connection point\r\n * @returns the current connection point\r\n */\r\n public disconnectFrom(endpoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPoint {\r\n const index = this._endpoints.indexOf(endpoint);\r\n\r\n if (index === -1) {\r\n return this;\r\n }\r\n\r\n this._endpoints.splice(index, 1);\r\n endpoint._connectedPoint = null;\r\n return this;\r\n }\r\n\r\n /**\r\n * Fill the list of excluded connection point types with all types other than those passed in the parameter\r\n * @param mask Types (ORed values of NodeMaterialBlockConnectionPointTypes) that are allowed, and thus will not be pushed to the excluded list\r\n */\r\n public addExcludedConnectionPointFromAllowedTypes(mask: number): void {\r\n let bitmask = 1;\r\n while (bitmask < NodeGeometryBlockConnectionPointTypes.All) {\r\n if (!(mask & bitmask)) {\r\n this.excludedConnectionPointTypes.push(bitmask);\r\n }\r\n bitmask = bitmask << 1;\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this point in a JSON representation\r\n * @param isInput defines if the connection point is an input (default is true)\r\n * @returns the serialized point object\r\n */\r\n public serialize(isInput = true): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.displayName = this.displayName;\r\n if (this.value !== undefined && this.value !== null) {\r\n if (this.value.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this.value.getClassName();\r\n serializationObject.value = this.value.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this.value;\r\n }\r\n }\r\n\r\n if (isInput && this.connectedPoint) {\r\n serializationObject.inputName = this.name;\r\n serializationObject.targetBlockId = this.connectedPoint.ownerBlock.uniqueId;\r\n serializationObject.targetConnectionName = this.connectedPoint.name;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public dispose() {\r\n this.onConnectionObservable.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"nodeGeometryBlockConnectionPoint.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Node/nodeGeometryBlockConnectionPoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC;AAIjG;;GAEG;AACH,MAAM,CAAN,IAAY,8CAOX;AAPD,WAAY,8CAA8C;IACtD,6BAA6B;IAC7B,+HAAU,CAAA;IACV,qDAAqD;IACrD,2IAAgB,CAAA;IAChB,sEAAsE;IACtE,uIAAc,CAAA;AAClB,CAAC,EAPW,8CAA8C,KAA9C,8CAA8C,QAOzD;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,oCAKX;AALD,WAAY,oCAAoC;IAC5C,YAAY;IACZ,iGAAK,CAAA;IACL,aAAa;IACb,mGAAM,CAAA;AACV,CAAC,EALW,oCAAoC,KAApC,oCAAoC,QAK/C;AAED;;GAEG;AACH,MAAM,OAAO,2BAA2B;IA0BpC,sCAAsC;IACtC,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAoDD;;OAEG;IACH,IAAW,IAAI;QACX,IAAI,IAAI,CAAC,KAAK,KAAK,qCAAqC,CAAC,UAAU,EAAE;YACjE,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC1B,OAAQ,IAAI,CAAC,WAAkC,CAAC,IAAI,CAAC;aACxD;YAED,IAAI,IAAI,CAAC,eAAe,EAAE;gBACtB,OAAO,IAAI,CA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3C,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { NodeGeometryBlock } from \"./nodeGeometryBlock\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"./Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { GeometryInputBlock } from \"./Blocks/geometryInputBlock\";\r\nimport type { NodeGeometryBuildState } from \"./nodeGeometryBuildState\";\r\n\r\n/**\r\n * Enum used to define the compatibility state between two connection points\r\n */\r\nexport enum NodeGeometryConnectionPointCompatibilityStates {\r\n /** Points are compatibles */\r\n Compatible,\r\n /** Points are incompatible because of their types */\r\n TypeIncompatible,\r\n /** Points are incompatible because they are in the same hierarchy **/\r\n HierarchyIssue,\r\n}\r\n\r\n/**\r\n * Defines the direction of a connection point\r\n */\r\nexport enum NodeGeometryConnectionPointDirection {\r\n /** Input */\r\n Input,\r\n /** Output */\r\n Output,\r\n}\r\n\r\n/**\r\n * Defines a connection point for a block\r\n */\r\nexport class NodeGeometryConnectionPoint {\r\n /** @internal */\r\n public _ownerBlock: NodeGeometryBlock;\r\n /** @internal */\r\n public _connectedPoint: Nullable<NodeGeometryConnectionPoint> = null;\r\n /** @internal */\r\n public _storedValue: any = null;\r\n /** @internal */\r\n public _storedFunction: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n\r\n /** @internal */\r\n public _acceptedConnectionPointType: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n private _endpoints = new Array<NodeGeometryConnectionPoint>();\r\n private _direction: NodeGeometryConnectionPointDirection;\r\n private _type = NodeGeometryBlockConnectionPointTypes.Geometry;\r\n\r\n /** @internal */\r\n public _linkedConnectionSource: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n /** @internal */\r\n public _typeConnectionSource: Nullable<NodeGeometryConnectionPoint> = null;\r\n\r\n /** @internal */\r\n public _defaultConnectionPointType: Nullable<NodeGeometryBlockConnectionPointTypes> = null;\r\n\r\n /** Gets the direction of the point */\r\n public get direction() {\r\n return this._direction;\r\n }\r\n\r\n /**\r\n * Gets or sets the additional types supported by this connection point\r\n */\r\n public acceptedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[] = [];\r\n\r\n /**\r\n * Gets or sets the additional types excluded by this connection point\r\n */\r\n public excludedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[] = [];\r\n\r\n /**\r\n * Observable triggered when this point is connected\r\n */\r\n public onConnectionObservable = new Observable<NodeGeometryConnectionPoint>();\r\n\r\n /**\r\n * Observable triggered when this point is disconnected\r\n */\r\n public onDisconnectionObservable = new Observable<NodeGeometryConnectionPoint>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this connection point is exposed on a frame\r\n */\r\n public isExposedOnFrame: boolean = false;\r\n\r\n /**\r\n * Gets or sets number indicating the position that the port is exposed to on a frame\r\n */\r\n public exposedPortPosition: number = -1;\r\n\r\n /**\r\n * Gets the default value used for this point at creation time\r\n */\r\n public defaultValue: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the default value used for this point if nothing is connected\r\n */\r\n public value: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the min value accepted for this point if nothing is connected\r\n */\r\n public valueMin: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the max value accepted for this point if nothing is connected\r\n */\r\n public valueMax: Nullable<any> = null;\r\n\r\n /**\r\n * Gets or sets the connection point type (default is float)\r\n */\r\n public get type(): NodeGeometryBlockConnectionPointTypes {\r\n if (this._type === NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n if (this._ownerBlock.isInput) {\r\n return (this._ownerBlock as GeometryInputBlock).type;\r\n }\r\n\r\n if (this._connectedPoint) {\r\n return this._connectedPoint.type;\r\n }\r\n\r\n if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) {\r\n return this._linkedConnectionSource.type;\r\n }\r\n }\r\n\r\n if (this._type === NodeGeometryBlockConnectionPointTypes.BasedOnInput) {\r\n if (this._typeConnectionSource) {\r\n if (!this._typeConnectionSource.isConnected && this._defaultConnectionPointType) {\r\n return this._defaultConnectionPointType;\r\n }\r\n return this._typeConnectionSource.type;\r\n } else if (this._defaultConnectionPointType) {\r\n return this._defaultConnectionPointType;\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n public set type(value: NodeGeometryBlockConnectionPointTypes) {\r\n this._type = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the connection point name\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Gets or sets the connection point display name\r\n */\r\n public displayName: string;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this connection point can be omitted\r\n */\r\n public isOptional: boolean;\r\n\r\n /**\r\n * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock\r\n */\r\n public get isConnected(): boolean {\r\n return this.connectedPoint !== null || this.hasEndpoints;\r\n }\r\n\r\n /** Get the other side of the connection (if any) */\r\n public get connectedPoint(): Nullable<NodeGeometryConnectionPoint> {\r\n return this._connectedPoint;\r\n }\r\n\r\n /** Get the block that owns this connection point */\r\n public get ownerBlock(): NodeGeometryBlock {\r\n return this._ownerBlock;\r\n }\r\n\r\n /** Get the block connected on the other side of this connection (if any) */\r\n public get sourceBlock(): Nullable<NodeGeometryBlock> {\r\n if (!this._connectedPoint) {\r\n return null;\r\n }\r\n\r\n return this._connectedPoint.ownerBlock;\r\n }\r\n\r\n /** Get the block connected on the endpoints of this connection (if any) */\r\n public get connectedBlocks(): Array<NodeGeometryBlock> {\r\n if (this._endpoints.length === 0) {\r\n return [];\r\n }\r\n\r\n return this._endpoints.map((e) => e.ownerBlock);\r\n }\r\n\r\n /** Gets the list of connected endpoints */\r\n public get endpoints() {\r\n return this._endpoints;\r\n }\r\n\r\n /** Gets a boolean indicating if that output point is connected to at least one input */\r\n public get hasEndpoints(): boolean {\r\n return this._endpoints && this._endpoints.length > 0;\r\n }\r\n\r\n /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */\r\n public get innerType() {\r\n if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected) {\r\n return this.type;\r\n }\r\n return this._type;\r\n }\r\n\r\n /** @internal */\r\n public _callCount = 0;\r\n\r\n /** @internal */\r\n public _executionCount = 0;\r\n\r\n /** @internal */\r\n public _resetCounters() {\r\n this._callCount = 0;\r\n this._executionCount = 0;\r\n }\r\n\r\n /**\r\n * Gets the number of times this point was called\r\n */\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n /**\r\n * Gets the number of times this point was executed\r\n */\r\n public get executionCount() {\r\n return this._executionCount;\r\n }\r\n\r\n /**\r\n * Gets the value represented by this connection point\r\n * @param state current evaluation state\r\n * @returns the connected value or the value if nothing is connected\r\n */\r\n public getConnectedValue(state: NodeGeometryBuildState) {\r\n if (this.isConnected) {\r\n if (this._connectedPoint?._storedFunction) {\r\n this._connectedPoint!._callCount++;\r\n this._connectedPoint!._executionCount++;\r\n return this._connectedPoint!._storedFunction(state);\r\n }\r\n this._connectedPoint!._callCount++;\r\n this._connectedPoint!._executionCount = 1;\r\n return this._connectedPoint!._storedValue;\r\n }\r\n this._callCount++;\r\n this._executionCount = 1;\r\n return this.value;\r\n }\r\n\r\n /**\r\n * Creates a new connection point\r\n * @param name defines the connection point name\r\n * @param ownerBlock defines the block hosting this connection point\r\n * @param direction defines the direction of the connection point\r\n */\r\n public constructor(name: string, ownerBlock: NodeGeometryBlock, direction: NodeGeometryConnectionPointDirection) {\r\n this._ownerBlock = ownerBlock;\r\n this.name = name;\r\n this._direction = direction;\r\n }\r\n\r\n /**\r\n * Gets the current class name e.g. \"NodeMaterialConnectionPoint\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeGeometryConnectionPoint\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the current point can be connected to another point\r\n * @param connectionPoint defines the other connection point\r\n * @returns a boolean\r\n */\r\n public canConnectTo(connectionPoint: NodeGeometryConnectionPoint) {\r\n return this.checkCompatibilityState(connectionPoint) === NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n }\r\n\r\n /**\r\n * Gets a number indicating if the current point can be connected to another point\r\n * @param connectionPoint defines the other connection point\r\n * @returns a number defining the compatibility state\r\n */\r\n public checkCompatibilityState(connectionPoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPointCompatibilityStates {\r\n const ownerBlock = this._ownerBlock;\r\n const otherBlock = connectionPoint.ownerBlock;\r\n\r\n if (this.type !== connectionPoint.type && connectionPoint.innerType !== NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n // Accepted types\r\n if (connectionPoint.acceptedConnectionPointTypes && connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1) {\r\n return NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n } else {\r\n return NodeGeometryConnectionPointCompatibilityStates.TypeIncompatible;\r\n }\r\n }\r\n\r\n // Excluded\r\n if (connectionPoint.excludedConnectionPointTypes && connectionPoint.excludedConnectionPointTypes.indexOf(this.type) !== -1) {\r\n return NodeGeometryConnectionPointCompatibilityStates.TypeIncompatible;\r\n }\r\n\r\n // Check hierarchy\r\n let targetBlock = otherBlock;\r\n let sourceBlock = ownerBlock;\r\n if (this.direction === NodeGeometryConnectionPointDirection.Input) {\r\n targetBlock = ownerBlock;\r\n sourceBlock = otherBlock;\r\n }\r\n\r\n if (targetBlock.isAnAncestorOf(sourceBlock)) {\r\n return NodeGeometryConnectionPointCompatibilityStates.HierarchyIssue;\r\n }\r\n\r\n return NodeGeometryConnectionPointCompatibilityStates.Compatible;\r\n }\r\n\r\n /**\r\n * Connect this point to another connection point\r\n * @param connectionPoint defines the other connection point\r\n * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)\r\n * @returns the current connection point\r\n */\r\n public connectTo(connectionPoint: NodeGeometryConnectionPoint, ignoreConstraints = false): NodeGeometryConnectionPoint {\r\n if (!ignoreConstraints && !this.canConnectTo(connectionPoint)) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Cannot connect these two connectors.\";\r\n }\r\n\r\n this._endpoints.push(connectionPoint);\r\n connectionPoint._connectedPoint = this;\r\n\r\n this.onConnectionObservable.notifyObservers(connectionPoint);\r\n connectionPoint.onConnectionObservable.notifyObservers(this);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Disconnect this point from one of his endpoint\r\n * @param endpoint defines the other connection point\r\n * @returns the current connection point\r\n */\r\n public disconnectFrom(endpoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPoint {\r\n const index = this._endpoints.indexOf(endpoint);\r\n\r\n if (index === -1) {\r\n return this;\r\n }\r\n\r\n this._endpoints.splice(index, 1);\r\n endpoint._connectedPoint = null;\r\n\r\n this.onDisconnectionObservable.notifyObservers(endpoint);\r\n endpoint.onDisconnectionObservable.notifyObservers(this);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Fill the list of excluded connection point types with all types other than those passed in the parameter\r\n * @param mask Types (ORed values of NodeMaterialBlockConnectionPointTypes) that are allowed, and thus will not be pushed to the excluded list\r\n */\r\n public addExcludedConnectionPointFromAllowedTypes(mask: number): void {\r\n let bitmask = 1;\r\n while (bitmask < NodeGeometryBlockConnectionPointTypes.All) {\r\n if (!(mask & bitmask)) {\r\n this.excludedConnectionPointTypes.push(bitmask);\r\n }\r\n bitmask = bitmask << 1;\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this point in a JSON representation\r\n * @param isInput defines if the connection point is an input (default is true)\r\n * @returns the serialized point object\r\n */\r\n public serialize(isInput = true): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.displayName = this.displayName;\r\n if (this.value !== undefined && this.value !== null) {\r\n if (this.value.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this.value.getClassName();\r\n serializationObject.value = this.value.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this.value;\r\n }\r\n }\r\n\r\n if (isInput && this.connectedPoint) {\r\n serializationObject.inputName = this.name;\r\n serializationObject.targetBlockId = this.connectedPoint.ownerBlock.uniqueId;\r\n serializationObject.targetConnectionName = this.connectedPoint.name;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public dispose() {\r\n this.onConnectionObservable.clear();\r\n this.onDisconnectionObservable.clear();\r\n }\r\n}\r\n"]}
@@ -71,6 +71,12 @@ export declare class GreasedLineTools {
71
71
  * @returns length of the line
72
72
  */
73
73
  static GetLineLength(data: Vector3[] | number[]): number;
74
+ /**
75
+ * Gets the the length from the beginning to each point of the line as array.
76
+ * @param data array of line points
77
+ * @returns length array of the line
78
+ */
79
+ static GetLineLengthArray(data: number[]): Float32Array;
74
80
  /**
75
81
  * Divides a segment into smaller segments.
76
82
  * A segment is a part of the line between it's two points.
@@ -220,6 +220,27 @@ export class GreasedLineTools {
220
220
  }
221
221
  return length;
222
222
  }
223
+ /**
224
+ * Gets the the length from the beginning to each point of the line as array.
225
+ * @param data array of line points
226
+ * @returns length array of the line
227
+ */
228
+ static GetLineLengthArray(data) {
229
+ const out = new Float32Array(data.length / 3);
230
+ let length = 0;
231
+ for (let index = 0, pointsLength = data.length / 3 - 1; index < pointsLength; index++) {
232
+ let x = data[index * 3 + 0];
233
+ let y = data[index * 3 + 1];
234
+ let z = data[index * 3 + 2];
235
+ x -= data[index * 3 + 3];
236
+ y -= data[index * 3 + 4];
237
+ z -= data[index * 3 + 5];
238
+ const currentLength = Math.sqrt(x * x + y * y + z * z);
239
+ length += currentLength;
240
+ out[index + 1] = length;
241
+ }
242
+ return out;
243
+ }
223
244
  /**
224
245
  * Divides a segment into smaller segments.
225
246
  * A segment is a part of the line between it's two points.