@babylonjs/core 6.20.1 → 6.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/Engines/nativeEngine.js +1 -1
  2. package/Engines/nativeEngine.js.map +1 -1
  3. package/Engines/thinEngine.js +2 -2
  4. package/Engines/thinEngine.js.map +1 -1
  5. package/Materials/effect.js +4 -4
  6. package/Materials/effect.js.map +1 -1
  7. package/Maths/math.vector.d.ts +2 -1
  8. package/Maths/math.vector.js +5 -4
  9. package/Maths/math.vector.js.map +1 -1
  10. package/Meshes/Node/Blocks/Matrices/alignBlock.js +1 -1
  11. package/Meshes/Node/Blocks/Matrices/alignBlock.js.map +1 -1
  12. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
  13. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  14. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -0
  15. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  16. package/Meshes/Node/Blocks/debugBlock.js +1 -0
  17. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  18. package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
  19. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  20. package/Meshes/Node/Blocks/geometryOptimizeBlock.js +1 -1
  21. package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
  22. package/Meshes/Node/Blocks/noiseBlock.js +1 -1
  23. package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
  24. package/Meshes/Node/Blocks/randomBlock.d.ts +12 -0
  25. package/Meshes/Node/Blocks/randomBlock.js +42 -1
  26. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  27. package/Meshes/Node/nodeGeometry.js +5 -0
  28. package/Meshes/Node/nodeGeometry.js.map +1 -1
  29. package/Meshes/Node/nodeGeometryBlock.d.ts +8 -3
  30. package/Meshes/Node/nodeGeometryBlock.js +8 -4
  31. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  32. package/Meshes/linesMesh.js +2 -2
  33. package/Meshes/linesMesh.js.map +1 -1
  34. package/Meshes/mesh.vertexData.js +28 -26
  35. package/Meshes/mesh.vertexData.js.map +1 -1
  36. package/Physics/v2/physicsBody.d.ts +1 -0
  37. package/Physics/v2/physicsBody.js +5 -0
  38. package/Physics/v2/physicsBody.js.map +1 -1
  39. package/Physics/v2/physicsShape.d.ts +1 -0
  40. package/Physics/v2/physicsShape.js +5 -0
  41. package/Physics/v2/physicsShape.js.map +1 -1
  42. package/Probes/reflectionProbe.d.ts +2 -1
  43. package/Probes/reflectionProbe.js +4 -1
  44. package/Probes/reflectionProbe.js.map +1 -1
  45. package/package.json +1 -1
@@ -49,7 +49,7 @@ export class AlignBlock extends NodeGeometryBlock {
49
49
  const result = new Matrix();
50
50
  source.normalize();
51
51
  target.normalize();
52
- Matrix.RotationAlignToRef(source, target, result);
52
+ Matrix.RotationAlignToRef(source, target, result, true);
53
53
  return result;
54
54
  };
55
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"alignBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/alignBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAC7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,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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 { Matrix, Vector3 } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to get a align matrix\r\n */\r\nexport class AlignBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new AlignBlock\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(\"source\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Up());\r\n this.registerInput(\"target\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Left());\r\n this.registerOutput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix);\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 \"AlignBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the matrix output component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.matrix._storedFunction = (state) => {\r\n const source = (this.source.getConnectedValue(state) as Vector3).clone();\r\n const target = (this.target.getConnectedValue(state) as Vector3).clone();\r\n const result = new Matrix();\r\n\r\n source.normalize();\r\n target.normalize();\r\n\r\n Matrix.RotationAlignToRef(source, target, result);\r\n\r\n return result;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AlignBlock\", AlignBlock);\r\n"]}
1
+ {"version":3,"file":"alignBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/alignBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAC7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAClG,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,MAAM,GAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAa,CAAC,KAAK,EAAE,CAAC;YACzE,MAAM,MAAM,GAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAa,CAAC,KAAK,EAAE,CAAC;YACzE,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAE5B,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,CAAC,SAAS,EAAE,CAAC;YAEnB,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YAExD,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,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 { Matrix, Vector3 } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to get a align matrix\r\n */\r\nexport class AlignBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new AlignBlock\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(\"source\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Up());\r\n this.registerInput(\"target\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Left());\r\n this.registerOutput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix);\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 \"AlignBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the matrix output component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.matrix._storedFunction = (state) => {\r\n const source = (this.source.getConnectedValue(state) as Vector3).clone();\r\n const target = (this.target.getConnectedValue(state) as Vector3).clone();\r\n const result = new Matrix();\r\n\r\n source.normalize();\r\n target.normalize();\r\n\r\n Matrix.RotationAlignToRef(source, target, result, true);\r\n\r\n return result;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AlignBlock\", AlignBlock);\r\n"]}
@@ -16,6 +16,7 @@ export class TeleportInBlock extends NodeGeometryBlock {
16
16
  constructor(name) {
17
17
  super(name);
18
18
  this._endpoints = [];
19
+ this._isTeleportIn = true;
19
20
  this.registerInput("input", NodeGeometryBlockConnectionPointTypes.AutoDetect);
20
21
  }
21
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"teleportInBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Teleport/teleportInBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAGlD,0CAA0C;IAC1C,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;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,CAAC,CAAC;QAEhD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACjC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,IAAI,CAAC;YAClD,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;SAC/B;IACL,CAAC;IAES,WAAW;QACjB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;YACpC,QAAQ,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;gBACxC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC;SACL;IACL,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { TeleportOutBlock } from \"./teleportOutBlock\";\r\n\r\n/**\r\n * Defines a block used to teleport a value to an endpoint\r\n */\r\nexport class TeleportInBlock extends NodeGeometryBlock {\r\n private _endpoints: TeleportOutBlock[] = [];\r\n\r\n /** Gets the list of attached endpoints */\r\n public get endpoints() {\r\n return this._endpoints;\r\n }\r\n\r\n /**\r\n * Create a new TeleportInBlock\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(\"input\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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 \"TeleportInBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n public _dumpCode(uniqueNames: string[], alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString = super._dumpCode(uniqueNames, alreadyDumped);\r\n\r\n for (const endpoint of this.endpoints) {\r\n if (alreadyDumped.indexOf(endpoint) === -1) {\r\n codeString += endpoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Add an enpoint to this block\r\n * @param endpoint define the endpoint to attach to\r\n */\r\n public attachToEndpoint(endpoint: TeleportOutBlock) {\r\n endpoint.detach();\r\n\r\n this._endpoints.push(endpoint);\r\n endpoint._entryPoint = this;\r\n endpoint._outputs[0]._typeConnectionSource = this._inputs[0];\r\n endpoint._tempEntryPointUniqueId = null;\r\n endpoint.name = \"> \" + this.name;\r\n }\r\n\r\n /**\r\n * Remove enpoint from this block\r\n * @param endpoint define the endpoint to remove\r\n */\r\n public detachFromEndpoint(endpoint: TeleportOutBlock) {\r\n const index = this._endpoints.indexOf(endpoint);\r\n\r\n if (index !== -1) {\r\n this._endpoints.splice(index, 1);\r\n endpoint._outputs[0]._typeConnectionSource = null;\r\n endpoint._entryPoint = null;\r\n }\r\n }\r\n\r\n protected _buildBlock() {\r\n for (const endpoint of this._endpoints) {\r\n endpoint.output._storedFunction = (state) => {\r\n return this.input.getConnectedValue(state);\r\n };\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TeleportInBlock\", TeleportInBlock);\r\n"]}
1
+ {"version":3,"file":"teleportInBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Teleport/teleportInBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AA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;QACxC,QAAQ,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrC,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,QAA0B;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEhD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACjC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,IAAI,CAAC;YAClD,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;SAC/B;IACL,CAAC;IAES,WAAW;QACjB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;YACpC,QAAQ,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;gBACxC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC;SACL;IACL,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { TeleportOutBlock } from \"./teleportOutBlock\";\r\n\r\n/**\r\n * Defines a block used to teleport a value to an endpoint\r\n */\r\nexport class TeleportInBlock extends NodeGeometryBlock {\r\n private _endpoints: TeleportOutBlock[] = [];\r\n\r\n /** Gets the list of attached endpoints */\r\n public get endpoints() {\r\n return this._endpoints;\r\n }\r\n\r\n /**\r\n * Create a new TeleportInBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n this._isTeleportIn = true;\r\n\r\n this.registerInput(\"input\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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 \"TeleportInBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n public _dumpCode(uniqueNames: string[], alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString = super._dumpCode(uniqueNames, alreadyDumped);\r\n\r\n for (const endpoint of this.endpoints) {\r\n if (alreadyDumped.indexOf(endpoint) === -1) {\r\n codeString += endpoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Add an enpoint to this block\r\n * @param endpoint define the endpoint to attach to\r\n */\r\n public attachToEndpoint(endpoint: TeleportOutBlock) {\r\n endpoint.detach();\r\n\r\n this._endpoints.push(endpoint);\r\n endpoint._entryPoint = this;\r\n endpoint._outputs[0]._typeConnectionSource = this._inputs[0];\r\n endpoint._tempEntryPointUniqueId = null;\r\n endpoint.name = \"> \" + this.name;\r\n }\r\n\r\n /**\r\n * Remove enpoint from this block\r\n * @param endpoint define the endpoint to remove\r\n */\r\n public detachFromEndpoint(endpoint: TeleportOutBlock) {\r\n const index = this._endpoints.indexOf(endpoint);\r\n\r\n if (index !== -1) {\r\n this._endpoints.splice(index, 1);\r\n endpoint._outputs[0]._typeConnectionSource = null;\r\n endpoint._entryPoint = null;\r\n }\r\n }\r\n\r\n protected _buildBlock() {\r\n for (const endpoint of this._endpoints) {\r\n endpoint.output._storedFunction = (state) => {\r\n return this.input.getConnectedValue(state);\r\n };\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TeleportInBlock\", TeleportInBlock);\r\n"]}
@@ -15,6 +15,7 @@ export class TeleportOutBlock extends NodeGeometryBlock {
15
15
  this._entryPoint = null;
16
16
  /** @internal */
17
17
  this._tempEntryPointUniqueId = null;
18
+ this._isTeleportOut = true;
18
19
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
19
20
  }
20
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"teleportOutBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Teleport/teleportOutBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAMnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAVhB,gBAAgB;QACT,gBAAW,GAA8B,IAAI,CAAC;QACrD,gBAAgB;QACT,4BAAuB,GAAqB,IAAI,CAAC;QASpD,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,8BAA8B;IACvB,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO;SACV;QACD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAES,WAAW;QACjB,aAAa;QACb,+BAA+B;IACnC,CAAC;IAES,gBAAgB,CAAC,KAA6B;QACpD,IAAI,IAAI,CAAC,UAAU,EAAE;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K,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,QAAQ,mCAAI,EAAE,CAAC;QAEjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAClE,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../../../types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { TeleportInBlock } from \"./teleportInBlock\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Defines a block used to receive a value from a teleport entry point\r\n */\r\nexport class TeleportOutBlock extends NodeGeometryBlock {\r\n /** @internal */\r\n public _entryPoint: Nullable<TeleportInBlock> = null;\r\n /** @internal */\r\n public _tempEntryPointUniqueId: Nullable<number> = null;\r\n\r\n /**\r\n * Create a new TeleportOutBlock\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.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n }\r\n\r\n /**\r\n * Gets the entry point\r\n */\r\n public get entryPoint() {\r\n return this._entryPoint;\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 \"TeleportOutBlock\";\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /** Detach from entry point */\r\n public detach() {\r\n if (!this._entryPoint) {\r\n return;\r\n }\r\n this._entryPoint.detachFromEndpoint(this);\r\n }\r\n\r\n protected _buildBlock() {\r\n // Do nothing\r\n // All work done by the emitter\r\n }\r\n\r\n protected _customBuildStep(state: NodeGeometryBuildState): void {\r\n if (this.entryPoint) {\r\n this.entryPoint.build(state);\r\n }\r\n }\r\n\r\n public _dumpCode(uniqueNames: string[], alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString: string = \"\";\r\n if (this.entryPoint) {\r\n if (alreadyDumped.indexOf(this.entryPoint) === -1) {\r\n codeString += this.entryPoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString + super._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n\r\n public _dumpCodeForOutputConnections(alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString = super._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n if (this.entryPoint) {\r\n codeString += this.entryPoint._dumpCodeForOutputConnections(alreadyDumped);\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Clone the current block to a new identical block\r\n * @returns a copy of the current block\r\n */\r\n public clone() {\r\n const clone = super.clone();\r\n\r\n if (this.entryPoint) {\r\n this.entryPoint.attachToEndpoint(clone as TeleportOutBlock);\r\n }\r\n\r\n return clone;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n if (this.entryPoint) {\r\n codeString += `${this.entryPoint._codeVariableName}.attachToEndpoint(${this._codeVariableName});\\n`;\r\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.entryPoint = this.entryPoint?.uniqueId ?? \"\";\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._tempEntryPointUniqueId = serializationObject.entryPoint;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TeleportOutBlock\", TeleportOutBlock);\r\n"]}
1
+ {"version":3,"file":"teleportOutBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Teleport/teleportOutBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAMnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAVhB,gBAAgB;QACT,gBAAW,GAA8B,IAAI,CAAC;QACrD,gBAAgB;QACT,4BAAuB,GAAqB,IAAI,CAAC;QASpD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAE3B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,8BAA8B;IACvB,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO;SACV;QACD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAES,WAAW;QACjB,aAAa;QACb,+BAA+B;IACnC,CAAC;IAES,gBAAgB,CAAC,KAA6B;QACpD,IAAI,IAAI,CAAC,UA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GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,QAAQ,mCAAI,EAAE,CAAC;QAEjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAClE,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../../../types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { TeleportInBlock } from \"./teleportInBlock\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Defines a block used to receive a value from a teleport entry point\r\n */\r\nexport class TeleportOutBlock extends NodeGeometryBlock {\r\n /** @internal */\r\n public _entryPoint: Nullable<TeleportInBlock> = null;\r\n /** @internal */\r\n public _tempEntryPointUniqueId: Nullable<number> = null;\r\n\r\n /**\r\n * Create a new TeleportOutBlock\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._isTeleportOut = true;\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n }\r\n\r\n /**\r\n * Gets the entry point\r\n */\r\n public get entryPoint() {\r\n return this._entryPoint;\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 \"TeleportOutBlock\";\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /** Detach from entry point */\r\n public detach() {\r\n if (!this._entryPoint) {\r\n return;\r\n }\r\n this._entryPoint.detachFromEndpoint(this);\r\n }\r\n\r\n protected _buildBlock() {\r\n // Do nothing\r\n // All work done by the emitter\r\n }\r\n\r\n protected _customBuildStep(state: NodeGeometryBuildState): void {\r\n if (this.entryPoint) {\r\n this.entryPoint.build(state);\r\n }\r\n }\r\n\r\n public _dumpCode(uniqueNames: string[], alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString: string = \"\";\r\n if (this.entryPoint) {\r\n if (alreadyDumped.indexOf(this.entryPoint) === -1) {\r\n codeString += this.entryPoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString + super._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n\r\n public _dumpCodeForOutputConnections(alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString = super._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n if (this.entryPoint) {\r\n codeString += this.entryPoint._dumpCodeForOutputConnections(alreadyDumped);\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Clone the current block to a new identical block\r\n * @returns a copy of the current block\r\n */\r\n public clone() {\r\n const clone = super.clone();\r\n\r\n if (this.entryPoint) {\r\n this.entryPoint.attachToEndpoint(clone as TeleportOutBlock);\r\n }\r\n\r\n return clone;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n if (this.entryPoint) {\r\n codeString += `${this.entryPoint._codeVariableName}.attachToEndpoint(${this._codeVariableName});\\n`;\r\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.entryPoint = this.entryPoint?.uniqueId ?? \"\";\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._tempEntryPointUniqueId = serializationObject.entryPoint;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TeleportOutBlock\", TeleportOutBlock);\r\n"]}
@@ -15,6 +15,7 @@ export class DebugBlock extends NodeGeometryBlock {
15
15
  * Gets the log entries
16
16
  */
17
17
  this.log = [];
18
+ this._isDebug = true;
18
19
  this.registerInput("input", NodeGeometryBlockConnectionPointTypes.AutoDetect);
19
20
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
20
21
  this._outputs[0]._typeConnectionSource = this._inputs[0];
@@ -1 +1 @@
1
- {"version":3,"file":"debugBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/debugBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAM7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAVhB;;WAEG;QACI,QAAG,GAAa,EAAE,CAAC;QAStB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;QAElF,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IACtG,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB;QACzB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,OAAO;SACV;QAED,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,OAAO,KAAK,CAAC;aAChB;YAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEhC,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Defines a block used to debug values going through it\r\n */\r\nexport class DebugBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets the log entries\r\n */\r\n public log: string[] = [];\r\n\r\n /**\r\n * Create a new DebugBlock\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(\"input\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the time spent to build this block (in ms)\r\n */\r\n public get buildExecutionTime() {\r\n return 0;\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 \"DebugBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the 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 if (!this.input.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.log = [];\r\n this.output._storedFunction = (state) => {\r\n const input = this.input.getConnectedValue(state);\r\n\r\n if (input === null || input === undefined) {\r\n this.log.push(\"null\");\r\n return input;\r\n }\r\n\r\n this.log.push(input.toString());\r\n\r\n return input;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.DebugBlock\", DebugBlock);\r\n"]}
1
+ {"version":3,"file":"debugBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/debugBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA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e,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,OAAO,KAAK,CAAC;aAChB;YAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEhC,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\n\r\n/**\r\n * Defines a block used to debug values going through it\r\n */\r\nexport class DebugBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets the log entries\r\n */\r\n public log: string[] = [];\r\n\r\n /**\r\n * Create a new DebugBlock\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._isDebug = true;\r\n\r\n this.registerInput(\"input\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\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.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the time spent to build this block (in ms)\r\n */\r\n public get buildExecutionTime() {\r\n return 0;\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 \"DebugBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the 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 if (!this.input.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.log = [];\r\n this.output._storedFunction = (state) => {\r\n const input = this.input.getConnectedValue(state);\r\n\r\n if (input === null || input === undefined) {\r\n this.log.push(\"null\");\r\n return input;\r\n }\r\n\r\n this.log.push(input.toString());\r\n\r\n return input;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.DebugBlock\", DebugBlock);\r\n"]}
@@ -98,6 +98,7 @@ export class GeometryInputBlock extends NodeGeometryBlock {
98
98
  /** Gets an observable raised when the value is changed */
99
99
  this.onValueChangedObservable = new Observable();
100
100
  this._type = type;
101
+ this._isInput = true;
101
102
  this.setDefaultValue();
102
103
  this.registerOutput("output", type);
103
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometryInputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryInputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAkBrD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G,mBAAmB,CAAC,eAAe,CAAC;QAC3D,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,IAAI,EAAE,CAAC;QAEnE,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE;YAChC,OAAO;SACV;QAED,IAAI,mBAAmB,CAAC,SAAS,KAAK,QAAQ,EAAE;YAC5C,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC;SACjD;aAAM;YACH,MAAM,SAAS,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACtE;SACJ;IACL,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { Observable } from \"../../../Misc/observable\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { GetClass, RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Matrix, Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to expose an input value\r\n */\r\nexport class GeometryInputBlock extends NodeGeometryBlock {\r\n private _storedValue: any;\r\n private _valueCallback: () => any;\r\n private _type: NodeGeometryBlockConnectionPointTypes = NodeGeometryBlockConnectionPointTypes.Undefined;\r\n private _contextualSource = NodeGeometryContextualSources.None;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public min: number = 0;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public max: number = 0;\r\n\r\n /** Gets or sets the group to use to display this block in the Inspector */\r\n public groupInInspector = \"\";\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<GeometryInputBlock>();\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.value != null) {\r\n if (!isNaN(this.value)) {\r\n this._type = NodeGeometryBlockConnectionPointTypes.Float;\r\n return this._type;\r\n }\r\n\r\n switch (this.value.getClassName()) {\r\n case \"Vector2\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n return this._type;\r\n case \"Vector3\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n return this._type;\r\n case \"Vector4\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n return this._type;\r\n case \"Matrix\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Matrix;\r\n return this._type;\r\n }\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the current connection point is a contextual value\r\n */\r\n public get isContextual(): boolean {\r\n return this._contextualSource !== NodeGeometryContextualSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the current contextual value\r\n */\r\n public get contextualValue(): NodeGeometryContextualSources {\r\n return this._contextualSource;\r\n }\r\n\r\n public set contextualValue(value: NodeGeometryContextualSources) {\r\n this._contextualSource = value;\r\n\r\n switch (value) {\r\n case NodeGeometryContextualSources.Positions:\r\n case NodeGeometryContextualSources.Normals:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n break;\r\n case NodeGeometryContextualSources.Colors:\r\n case NodeGeometryContextualSources.Tangents:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n break;\r\n case NodeGeometryContextualSources.UV:\r\n case NodeGeometryContextualSources.UV2:\r\n case NodeGeometryContextualSources.UV3:\r\n case NodeGeometryContextualSources.UV4:\r\n case NodeGeometryContextualSources.UV5:\r\n case NodeGeometryContextualSources.UV6:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n break;\r\n case NodeGeometryContextualSources.VertexID:\r\n case NodeGeometryContextualSources.GeometryID:\r\n case NodeGeometryContextualSources.CollectionID:\r\n case NodeGeometryContextualSources.FaceID:\r\n case NodeGeometryContextualSources.LoopID:\r\n case NodeGeometryContextualSources.InstanceID:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Int;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new InputBlock\r\n * @param name defines the block name\r\n * @param type defines the type of the input (can be set to NodeGeometryBlockConnectionPointTypes.AutoDetect)\r\n */\r\n public constructor(name: string, type: NodeGeometryBlockConnectionPointTypes = NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n super(name);\r\n\r\n this._type = type;\r\n\r\n this.setDefaultValue();\r\n\r\n this.registerOutput(\"output\", type);\r\n }\r\n\r\n /**\r\n * Gets or sets the value of that point.\r\n * Please note that this value will be ignored if valueCallback is defined\r\n */\r\n public get value(): any {\r\n return this._storedValue;\r\n }\r\n\r\n public set value(value: any) {\r\n if (this.type === NodeGeometryBlockConnectionPointTypes.Float) {\r\n if (this.min !== this.max) {\r\n value = Math.max(this.min, value);\r\n value = Math.min(this.max, value);\r\n }\r\n }\r\n\r\n this._storedValue = value;\r\n\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets a callback used to get the value of that point.\r\n * Please note that setting this value will force the connection point to ignore the value property\r\n */\r\n public get valueCallback(): () => any {\r\n return this._valueCallback;\r\n }\r\n\r\n public set valueCallback(value: () => any) {\r\n this._valueCallback = value;\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 \"GeometryInputBlock\";\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 /**\r\n * Set the input block to its default value (based on its type)\r\n */\r\n public setDefaultValue() {\r\n this.contextualValue = NodeGeometryContextualSources.None;\r\n switch (this.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float:\r\n this.value = 0;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n this.value = Vector2.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n this.value = Vector3.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n this.value = Vector4.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Matrix:\r\n this.value = Matrix.Identity();\r\n break;\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (this.isContextual) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getContextualValue(this._contextualSource);\r\n };\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = this.value;\r\n }\r\n }\r\n\r\n public dispose() {\r\n this.onValueChangedObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const variableName = this._codeVariableName;\r\n\r\n if (this.isContextual) {\r\n return (\r\n super._dumpPropertiesCode() + `${variableName}.contextualValue = BABYLON.NodeGeometryContextualSources.${NodeGeometryContextualSources[this._contextualSource]};\\n`\r\n );\r\n }\r\n const codes: string[] = [];\r\n\r\n let valueString = \"\";\r\n\r\n switch (this.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Float:\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n valueString = `${this.value}`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n valueString = `new BABYLON.Vector2(${this.value.x}, ${this.value.y})`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n valueString = `new BABYLON.Vector3(${this.value.x}, ${this.value.y}, ${this.value.z})`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n valueString = `new BABYLON.Vector4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;\r\n break;\r\n }\r\n\r\n // Common Property \"Value\"\r\n codes.push(`${variableName}.value = ${valueString}`);\r\n\r\n // Float-Value-Specific Properties\r\n if (this.type === NodeGeometryBlockConnectionPointTypes.Float || this.type === NodeGeometryBlockConnectionPointTypes.Int) {\r\n codes.push(`${variableName}.min = ${this.min}`, `${variableName}.max = ${this.max}`);\r\n }\r\n\r\n codes.push(\"\");\r\n\r\n return super._dumpPropertiesCode() + codes.join(\";\\n\");\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.type = this.type;\r\n serializationObject.contextualValue = this.contextualValue;\r\n serializationObject.min = this.min;\r\n serializationObject.max = this.max;\r\n serializationObject.groupInInspector = this.groupInInspector;\r\n\r\n if (this._storedValue !== null && !this.isContextual) {\r\n if (this._storedValue.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this._storedValue.getClassName();\r\n serializationObject.value = this._storedValue.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this._storedValue;\r\n }\r\n }\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._type = serializationObject.type;\r\n\r\n this.contextualValue = serializationObject.contextualValue;\r\n this.min = serializationObject.min || 0;\r\n this.max = serializationObject.max || 0;\r\n this.groupInInspector = serializationObject.groupInInspector || \"\";\r\n\r\n if (!serializationObject.valueType) {\r\n return;\r\n }\r\n\r\n if (serializationObject.valueType === \"number\") {\r\n this._storedValue = serializationObject.value;\r\n } else {\r\n const valueType = GetClass(serializationObject.valueType);\r\n\r\n if (valueType) {\r\n this._storedValue = valueType.FromArray(serializationObject.value);\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryInputBlock\", GeometryInputBlock);\r\n"]}
1
+ {"version":3,"file":"geometryInputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryInputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAkBrD;;OAEG;IACH,IAAW,IAAI;QACX,IAAI,IAAI,CAAC,KAAK,KAAK,qCAAqC,CAAC,UAAU,EAAE;YACjE,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;oBACpB,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAC,KAAK,CAAC;oBACzD,OAAO,IAAI,CAAC,KAAK,CAAC;iBACrB;gBAED,QAAQ,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE;oBAC/B,KAAK,SAAS;wBACV,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAC,OAAO,CAAC;wBAC3D,OAAO,IAAI,CAAC,KAAK,CAAC;oBACtB,KAAK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S,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACtE;SACJ;IACL,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { Observable } from \"../../../Misc/observable\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { GetClass, RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Matrix, Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to expose an input value\r\n */\r\nexport class GeometryInputBlock extends NodeGeometryBlock {\r\n private _storedValue: any;\r\n private _valueCallback: () => any;\r\n private _type: NodeGeometryBlockConnectionPointTypes = NodeGeometryBlockConnectionPointTypes.Undefined;\r\n private _contextualSource = NodeGeometryContextualSources.None;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public min: number = 0;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public max: number = 0;\r\n\r\n /** Gets or sets the group to use to display this block in the Inspector */\r\n public groupInInspector = \"\";\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<GeometryInputBlock>();\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.value != null) {\r\n if (!isNaN(this.value)) {\r\n this._type = NodeGeometryBlockConnectionPointTypes.Float;\r\n return this._type;\r\n }\r\n\r\n switch (this.value.getClassName()) {\r\n case \"Vector2\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n return this._type;\r\n case \"Vector3\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n return this._type;\r\n case \"Vector4\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n return this._type;\r\n case \"Matrix\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Matrix;\r\n return this._type;\r\n }\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the current connection point is a contextual value\r\n */\r\n public get isContextual(): boolean {\r\n return this._contextualSource !== NodeGeometryContextualSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the current contextual value\r\n */\r\n public get contextualValue(): NodeGeometryContextualSources {\r\n return this._contextualSource;\r\n }\r\n\r\n public set contextualValue(value: NodeGeometryContextualSources) {\r\n this._contextualSource = value;\r\n\r\n switch (value) {\r\n case NodeGeometryContextualSources.Positions:\r\n case NodeGeometryContextualSources.Normals:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n break;\r\n case NodeGeometryContextualSources.Colors:\r\n case NodeGeometryContextualSources.Tangents:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n break;\r\n case NodeGeometryContextualSources.UV:\r\n case NodeGeometryContextualSources.UV2:\r\n case NodeGeometryContextualSources.UV3:\r\n case NodeGeometryContextualSources.UV4:\r\n case NodeGeometryContextualSources.UV5:\r\n case NodeGeometryContextualSources.UV6:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n break;\r\n case NodeGeometryContextualSources.VertexID:\r\n case NodeGeometryContextualSources.GeometryID:\r\n case NodeGeometryContextualSources.CollectionID:\r\n case NodeGeometryContextualSources.FaceID:\r\n case NodeGeometryContextualSources.LoopID:\r\n case NodeGeometryContextualSources.InstanceID:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Int;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new InputBlock\r\n * @param name defines the block name\r\n * @param type defines the type of the input (can be set to NodeGeometryBlockConnectionPointTypes.AutoDetect)\r\n */\r\n public constructor(name: string, type: NodeGeometryBlockConnectionPointTypes = NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n super(name);\r\n\r\n this._type = type;\r\n this._isInput = true;\r\n\r\n this.setDefaultValue();\r\n\r\n this.registerOutput(\"output\", type);\r\n }\r\n\r\n /**\r\n * Gets or sets the value of that point.\r\n * Please note that this value will be ignored if valueCallback is defined\r\n */\r\n public get value(): any {\r\n return this._storedValue;\r\n }\r\n\r\n public set value(value: any) {\r\n if (this.type === NodeGeometryBlockConnectionPointTypes.Float) {\r\n if (this.min !== this.max) {\r\n value = Math.max(this.min, value);\r\n value = Math.min(this.max, value);\r\n }\r\n }\r\n\r\n this._storedValue = value;\r\n\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets a callback used to get the value of that point.\r\n * Please note that setting this value will force the connection point to ignore the value property\r\n */\r\n public get valueCallback(): () => any {\r\n return this._valueCallback;\r\n }\r\n\r\n public set valueCallback(value: () => any) {\r\n this._valueCallback = value;\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 \"GeometryInputBlock\";\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 /**\r\n * Set the input block to its default value (based on its type)\r\n */\r\n public setDefaultValue() {\r\n this.contextualValue = NodeGeometryContextualSources.None;\r\n switch (this.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float:\r\n this.value = 0;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n this.value = Vector2.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n this.value = Vector3.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n this.value = Vector4.Zero();\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Matrix:\r\n this.value = Matrix.Identity();\r\n break;\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (this.isContextual) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getContextualValue(this._contextualSource);\r\n };\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = this.value;\r\n }\r\n }\r\n\r\n public dispose() {\r\n this.onValueChangedObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const variableName = this._codeVariableName;\r\n\r\n if (this.isContextual) {\r\n return (\r\n super._dumpPropertiesCode() + `${variableName}.contextualValue = BABYLON.NodeGeometryContextualSources.${NodeGeometryContextualSources[this._contextualSource]};\\n`\r\n );\r\n }\r\n const codes: string[] = [];\r\n\r\n let valueString = \"\";\r\n\r\n switch (this.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Float:\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n valueString = `${this.value}`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n valueString = `new BABYLON.Vector2(${this.value.x}, ${this.value.y})`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n valueString = `new BABYLON.Vector3(${this.value.x}, ${this.value.y}, ${this.value.z})`;\r\n break;\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n valueString = `new BABYLON.Vector4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;\r\n break;\r\n }\r\n\r\n // Common Property \"Value\"\r\n codes.push(`${variableName}.value = ${valueString}`);\r\n\r\n // Float-Value-Specific Properties\r\n if (this.type === NodeGeometryBlockConnectionPointTypes.Float || this.type === NodeGeometryBlockConnectionPointTypes.Int) {\r\n codes.push(`${variableName}.min = ${this.min}`, `${variableName}.max = ${this.max}`);\r\n }\r\n\r\n codes.push(\"\");\r\n\r\n return super._dumpPropertiesCode() + codes.join(\";\\n\");\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.type = this.type;\r\n serializationObject.contextualValue = this.contextualValue;\r\n serializationObject.min = this.min;\r\n serializationObject.max = this.max;\r\n serializationObject.groupInInspector = this.groupInInspector;\r\n\r\n if (this._storedValue !== null && !this.isContextual) {\r\n if (this._storedValue.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this._storedValue.getClassName();\r\n serializationObject.value = this._storedValue.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this._storedValue;\r\n }\r\n }\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._type = serializationObject.type;\r\n\r\n this.contextualValue = serializationObject.contextualValue;\r\n this.min = serializationObject.min || 0;\r\n this.max = serializationObject.max || 0;\r\n this.groupInInspector = serializationObject.groupInInspector || \"\";\r\n\r\n if (!serializationObject.valueType) {\r\n return;\r\n }\r\n\r\n if (serializationObject.valueType === \"number\") {\r\n this._storedValue = serializationObject.value;\r\n } else {\r\n const valueType = GetClass(serializationObject.valueType);\r\n\r\n if (valueType) {\r\n this._storedValue = valueType.FromArray(serializationObject.value);\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryInputBlock\", GeometryInputBlock);\r\n"]}
@@ -20,7 +20,7 @@ export class GeometryOptimizeBlock extends NodeGeometryBlock {
20
20
  * Gets or sets a boolean indicating that this block can evaluate context
21
21
  * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
22
22
  */
23
- this.evaluateContext = false;
23
+ this.evaluateContext = true;
24
24
  /**
25
25
  * Define the epsilon used to compare similar positions
26
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"geometryOptimizeBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOptimizeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGnG,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAcxD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAlBhB;;;WAGG;QAEI,oBAAe,GAAG,KAAK,CAAC;QAE/B;;WAEG;QAEI,YAAO,GAAG,OAAO,CAAC;QASrB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,uBAAuB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,MAAM,IAAI,GAAG,CAAC,KAA6B,EA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AEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC;IAC/C,CAAC;CACJ;AAlHU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC1F;AAMxB;IADN,sBAAsB,CAAC,SAAS,EAAE,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;sDACrF;AA8G7B,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport type { FloatArray } from \"../../../types\";\r\nimport { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n/**\r\n * Block used to extract unique positions from a geometry\r\n */\r\nexport class GeometryOptimizeBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = false;\r\n\r\n /**\r\n * Define the epsilon used to compare similar positions\r\n */\r\n @editableInPropertyPage(\"Epsilon\", PropertyTypeForEdition.Float, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public epsilon = Epsilon;\r\n\r\n /**\r\n * Creates a new GeometryOptimizeBlock\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(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\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 \"GeometryOptimizeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n const newPositions: FloatArray = [];\r\n const newIndicesMap: { [key: number]: number } = {};\r\n\r\n for (let index = 0; index < vertexData.positions.length; index += 3) {\r\n const x = vertexData.positions[index];\r\n const y = vertexData.positions[index + 1];\r\n const z = vertexData.positions[index + 2];\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {\r\n if (\r\n Scalar.WithinEpsilon(x, newPositions[checkIndex], this.epsilon) &&\r\n Scalar.WithinEpsilon(y, newPositions[checkIndex + 1], this.epsilon) &&\r\n Scalar.WithinEpsilon(z, newPositions[checkIndex + 2], this.epsilon)\r\n ) {\r\n newIndicesMap[index / 3] = checkIndex / 3;\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndicesMap[index / 3] = newPositions.length / 3;\r\n newPositions.push(x, y, z);\r\n }\r\n }\r\n const newVertexData = new VertexData();\r\n newVertexData.positions = newPositions;\r\n newVertexData.indices = vertexData.indices.map((index: number) => newIndicesMap[index]);\r\n\r\n return newVertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.epsilon = ${this.epsilon};\\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.evaluateContext = this.evaluateContext;\r\n serializationObject.epsilon = this.epsilon;\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.evaluateContext = serializationObject.evaluateContext;\r\n this.epsilon = serializationObject.epsilon;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOptimizeBlock\", GeometryOptimizeBlock);\r\n"]}
1
+ {"version":3,"file":"geometryOptimizeBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOptimizeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGnG,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAA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AU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;sDACrF;AA8G7B,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport type { FloatArray } from \"../../../types\";\r\nimport { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n/**\r\n * Block used to extract unique positions from a geometry\r\n */\r\nexport class GeometryOptimizeBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Define the epsilon used to compare similar positions\r\n */\r\n @editableInPropertyPage(\"Epsilon\", PropertyTypeForEdition.Float, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public epsilon = Epsilon;\r\n\r\n /**\r\n * Creates a new GeometryOptimizeBlock\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(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\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 \"GeometryOptimizeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n const newPositions: FloatArray = [];\r\n const newIndicesMap: { [key: number]: number } = {};\r\n\r\n for (let index = 0; index < vertexData.positions.length; index += 3) {\r\n const x = vertexData.positions[index];\r\n const y = vertexData.positions[index + 1];\r\n const z = vertexData.positions[index + 2];\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {\r\n if (\r\n Scalar.WithinEpsilon(x, newPositions[checkIndex], this.epsilon) &&\r\n Scalar.WithinEpsilon(y, newPositions[checkIndex + 1], this.epsilon) &&\r\n Scalar.WithinEpsilon(z, newPositions[checkIndex + 2], this.epsilon)\r\n ) {\r\n newIndicesMap[index / 3] = checkIndex / 3;\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndicesMap[index / 3] = newPositions.length / 3;\r\n newPositions.push(x, y, z);\r\n }\r\n }\r\n const newVertexData = new VertexData();\r\n newVertexData.positions = newPositions;\r\n newVertexData.indices = vertexData.indices.map((index: number) => newIndicesMap[index]);\r\n\r\n return newVertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.epsilon = ${this.epsilon};\\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.evaluateContext = this.evaluateContext;\r\n serializationObject.epsilon = this.epsilon;\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.evaluateContext = serializationObject.evaluateContext;\r\n this.epsilon = serializationObject.epsilon;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOptimizeBlock\", GeometryOptimizeBlock);\r\n"]}
@@ -128,7 +128,7 @@ export class NoiseBlock extends NodeGeometryBlock {
128
128
  * @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533
129
129
  */
130
130
  noise(octaves, roughness, _position, offset, scale) {
131
- const position = new Vector3(_position.x + offset.x * scale, _position.y + offset.y * scale, _position.z + offset.z * scale);
131
+ const position = new Vector3(_position.x * scale + offset.x, _position.y * scale + offset.y, _position.z * scale + offset.z);
132
132
  let fscale = 1.0;
133
133
  let amp = 1.0;
134
134
  let maxamp = 0.0;
@@ -1 +1 @@
1
- {"version":3,"file":"noiseBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/noiseBlock.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;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;I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ometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { Vector3 } from \"../../../Maths/math.vector\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to get a noise value\r\n */\r\nexport class NoiseBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new NoiseBlock\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(\"offset\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scale\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\r\n\r\n this.registerInput(\"octaves\", NodeGeometryBlockConnectionPointTypes.Float, true, 2, 0, 16);\r\n this.registerInput(\"roughness\", NodeGeometryBlockConnectionPointTypes.Float, true, 0.5, 0, 1);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\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 \"NoiseBlock\";\r\n }\r\n\r\n /**\r\n * Gets the offset input component\r\n */\r\n public get offset(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the octaves input component\r\n */\r\n public get octaves(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the roughtness input component\r\n */\r\n public get roughness(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\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 private _negateIf(value: number, condition: number) {\r\n return condition !== 0 ? -value : value;\r\n }\r\n\r\n private _noiseGrad(hash: number, x: number, y: number, z: number) {\r\n const h = hash & 15;\r\n const u = h < 8 ? x : y;\r\n const vt = h === 12 || h == 14 ? x : z;\r\n const v = h < 4 ? y : vt;\r\n return this._negateIf(u, h & u) + this._negateIf(v, h & 2);\r\n }\r\n\r\n private _fade(t: number) {\r\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\r\n }\r\n\r\n private _hashBitRotate(x: number, k: number) {\r\n return (x << k) | (x >> (32 - k));\r\n }\r\n\r\n private _hash(kx: number, ky: number, kz: number) {\r\n let a: number, b: number, c: number;\r\n a = b = c = 0xdeadbeef + (3 << 2) + 13;\r\n\r\n c += kz;\r\n b += ky;\r\n a += kx;\r\n\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 14);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 11);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 25);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 16);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 4);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 14);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 24);\r\n\r\n return c;\r\n }\r\n\r\n private _mix(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, x: number, y: number, z: number) {\r\n const x1 = 1.0 - x;\r\n const y1 = 1.0 - y;\r\n const z1 = 1.0 - z;\r\n return z1 * (y1 * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x)) + z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x));\r\n }\r\n\r\n private _perlinNoise(position: Vector3) {\r\n const X = (position.x | 0) - (position.x < 0 ? 1 : 0);\r\n const Y = (position.y | 0) - (position.y < 0 ? 1 : 0);\r\n const Z = (position.z | 0) - (position.z < 0 ? 1 : 0);\r\n\r\n const fx = position.x - X;\r\n const fy = position.y - Y;\r\n const fz = position.z - Z;\r\n\r\n const u = this._fade(fx);\r\n const v = this._fade(fy);\r\n const w = this._fade(fz);\r\n\r\n return this._mix(\r\n this._noiseGrad(this._hash(X, Y, Z), fx, fy, fz),\r\n this._noiseGrad(this._hash(X + 1, Y, Z), fx - 1, fy, fz),\r\n this._noiseGrad(this._hash(X, Y + 1, Z), fx, fy - 1, fz),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z), fx - 1, fy - 1, fz),\r\n this._noiseGrad(this._hash(X, Y, Z + 1), fx, fy, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y, Z + 1), fx - 1, fy, fz - 1),\r\n this._noiseGrad(this._hash(X, Y + 1, Z + 1), fx, fy - 1, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z + 1), fx - 1, fy - 1, fz - 1),\r\n u,\r\n v,\r\n w\r\n );\r\n }\r\n\r\n private _perlinSigned(position: Vector3) {\r\n return this._perlinNoise(position) * 0.982;\r\n }\r\n\r\n private _perlin(position: Vector3) {\r\n return this._perlinSigned(position) / 2.0 + 0.5;\r\n }\r\n\r\n /**\r\n * Gets a perlin noise value\r\n * @param octaves\r\n * @param roughness\r\n * @param position\r\n * @returns a value between 0 and 1\r\n * @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533\r\n */\r\n noise(octaves: number, roughness: number, _position: Vector3, offset: Vector3, scale: number) {\r\n const position = new Vector3(_position.x + offset.x * scale, _position.y + offset.y * scale, _position.z + offset.z * scale);\r\n\r\n let fscale = 1.0;\r\n let amp = 1.0;\r\n let maxamp = 0.0;\r\n let sum = 0.0;\r\n octaves = Scalar.Clamp(octaves, 0, 15.0);\r\n const step = octaves | 0;\r\n\r\n for (let i = 0; i <= step; i++) {\r\n const t = this._perlin(position.scale(fscale));\r\n sum += t * amp;\r\n maxamp += amp;\r\n amp *= Scalar.Clamp(roughness, 0.0, 1.0);\r\n fscale *= 2.0;\r\n }\r\n\r\n const rmd = octaves - Math.floor(octaves);\r\n if (rmd == 0.0) {\r\n return sum / maxamp;\r\n }\r\n\r\n const t = this._perlin(position.scale(fscale));\r\n let sum2 = sum + t * amp;\r\n sum /= maxamp;\r\n sum2 /= maxamp + amp;\r\n return (1.0 - rmd) * sum + rmd * sum2;\r\n }\r\n\r\n protected _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n const position = state.getContextualValue(NodeGeometryContextualSources.Positions) as Vector3;\r\n const octaves = this.octaves.getConnectedValue(state);\r\n const roughness = this.roughness.getConnectedValue(state);\r\n\r\n const offset = this.offset.getConnectedValue(state) as Vector3;\r\n const scale = this.scale.getConnectedValue(state);\r\n\r\n return this.noise(octaves, roughness, position, offset, scale);\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NoiseBlock\", NoiseBlock);\r\n"]}
1
+ {"version":3,"file":"noiseBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/noiseBlock.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;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAC7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAClG,IAAI,CAAC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;SACvB;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/C,IAAI,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACzB,GAAG,IAAI,MAAM,CAAC;QACd,IAAI,IAAI,MAAM,GAAG,GAAG,CAAC;QACrB,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IAC1C,CAAC;IAES,WAAW;QACjB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,SAAS,CAAY,CAAC;YAC9F,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACtD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAE1D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAY,CAAC;YAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACnE,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,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 { Vector3 } from \"../../../Maths/math.vector\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to get a noise value\r\n */\r\nexport class NoiseBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new NoiseBlock\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(\"offset\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scale\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\r\n\r\n this.registerInput(\"octaves\", NodeGeometryBlockConnectionPointTypes.Float, true, 2, 0, 16);\r\n this.registerInput(\"roughness\", NodeGeometryBlockConnectionPointTypes.Float, true, 0.5, 0, 1);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\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 \"NoiseBlock\";\r\n }\r\n\r\n /**\r\n * Gets the offset input component\r\n */\r\n public get offset(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the octaves input component\r\n */\r\n public get octaves(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the roughtness input component\r\n */\r\n public get roughness(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\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 private _negateIf(value: number, condition: number) {\r\n return condition !== 0 ? -value : value;\r\n }\r\n\r\n private _noiseGrad(hash: number, x: number, y: number, z: number) {\r\n const h = hash & 15;\r\n const u = h < 8 ? x : y;\r\n const vt = h === 12 || h == 14 ? x : z;\r\n const v = h < 4 ? y : vt;\r\n return this._negateIf(u, h & u) + this._negateIf(v, h & 2);\r\n }\r\n\r\n private _fade(t: number) {\r\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\r\n }\r\n\r\n private _hashBitRotate(x: number, k: number) {\r\n return (x << k) | (x >> (32 - k));\r\n }\r\n\r\n private _hash(kx: number, ky: number, kz: number) {\r\n let a: number, b: number, c: number;\r\n a = b = c = 0xdeadbeef + (3 << 2) + 13;\r\n\r\n c += kz;\r\n b += ky;\r\n a += kx;\r\n\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 14);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 11);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 25);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 16);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 4);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 14);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 24);\r\n\r\n return c;\r\n }\r\n\r\n private _mix(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, x: number, y: number, z: number) {\r\n const x1 = 1.0 - x;\r\n const y1 = 1.0 - y;\r\n const z1 = 1.0 - z;\r\n return z1 * (y1 * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x)) + z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x));\r\n }\r\n\r\n private _perlinNoise(position: Vector3) {\r\n const X = (position.x | 0) - (position.x < 0 ? 1 : 0);\r\n const Y = (position.y | 0) - (position.y < 0 ? 1 : 0);\r\n const Z = (position.z | 0) - (position.z < 0 ? 1 : 0);\r\n\r\n const fx = position.x - X;\r\n const fy = position.y - Y;\r\n const fz = position.z - Z;\r\n\r\n const u = this._fade(fx);\r\n const v = this._fade(fy);\r\n const w = this._fade(fz);\r\n\r\n return this._mix(\r\n this._noiseGrad(this._hash(X, Y, Z), fx, fy, fz),\r\n this._noiseGrad(this._hash(X + 1, Y, Z), fx - 1, fy, fz),\r\n this._noiseGrad(this._hash(X, Y + 1, Z), fx, fy - 1, fz),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z), fx - 1, fy - 1, fz),\r\n this._noiseGrad(this._hash(X, Y, Z + 1), fx, fy, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y, Z + 1), fx - 1, fy, fz - 1),\r\n this._noiseGrad(this._hash(X, Y + 1, Z + 1), fx, fy - 1, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z + 1), fx - 1, fy - 1, fz - 1),\r\n u,\r\n v,\r\n w\r\n );\r\n }\r\n\r\n private _perlinSigned(position: Vector3) {\r\n return this._perlinNoise(position) * 0.982;\r\n }\r\n\r\n private _perlin(position: Vector3) {\r\n return this._perlinSigned(position) / 2.0 + 0.5;\r\n }\r\n\r\n /**\r\n * Gets a perlin noise value\r\n * @param octaves\r\n * @param roughness\r\n * @param position\r\n * @returns a value between 0 and 1\r\n * @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533\r\n */\r\n noise(octaves: number, roughness: number, _position: Vector3, offset: Vector3, scale: number) {\r\n const position = new Vector3(_position.x * scale + offset.x, _position.y * scale + offset.y, _position.z * scale + offset.z);\r\n\r\n let fscale = 1.0;\r\n let amp = 1.0;\r\n let maxamp = 0.0;\r\n let sum = 0.0;\r\n octaves = Scalar.Clamp(octaves, 0, 15.0);\r\n const step = octaves | 0;\r\n\r\n for (let i = 0; i <= step; i++) {\r\n const t = this._perlin(position.scale(fscale));\r\n sum += t * amp;\r\n maxamp += amp;\r\n amp *= Scalar.Clamp(roughness, 0.0, 1.0);\r\n fscale *= 2.0;\r\n }\r\n\r\n const rmd = octaves - Math.floor(octaves);\r\n if (rmd == 0.0) {\r\n return sum / maxamp;\r\n }\r\n\r\n const t = this._perlin(position.scale(fscale));\r\n let sum2 = sum + t * amp;\r\n sum /= maxamp;\r\n sum2 /= maxamp + amp;\r\n return (1.0 - rmd) * sum + rmd * sum2;\r\n }\r\n\r\n protected _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n const position = state.getContextualValue(NodeGeometryContextualSources.Positions) as Vector3;\r\n const octaves = this.octaves.getConnectedValue(state);\r\n const roughness = this.roughness.getConnectedValue(state);\r\n\r\n const offset = this.offset.getConnectedValue(state) as Vector3;\r\n const scale = this.scale.getConnectedValue(state);\r\n\r\n return this.noise(octaves, roughness, position, offset, scale);\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NoiseBlock\", NoiseBlock);\r\n"]}
@@ -4,6 +4,11 @@ import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnection
4
4
  * Block used to get a random number
5
5
  */
6
6
  export declare class RandomBlock extends NodeGeometryBlock {
7
+ private _currentLoopId;
8
+ /**
9
+ * Gets or sets a boolean indicating that this block will generate a new value only once per loop
10
+ */
11
+ lockPerLoop: boolean;
7
12
  /**
8
13
  * Create a new RandomBlock
9
14
  * @param name defines the block name
@@ -28,4 +33,11 @@ export declare class RandomBlock extends NodeGeometryBlock {
28
33
  get output(): NodeGeometryConnectionPoint;
29
34
  autoConfigure(): void;
30
35
  protected _buildBlock(): void;
36
+ protected _dumpPropertiesCode(): string;
37
+ /**
38
+ * Serializes this block in a JSON representation
39
+ * @returns the serialized block object
40
+ */
41
+ serialize(): any;
42
+ _deserialize(serializationObject: any): void;
31
43
  }
@@ -1,8 +1,11 @@
1
+ import { __decorate } from "../../../tslib.es6.js";
1
2
  import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
2
3
  import { RegisterClass } from "../../../Misc/typeStore.js";
3
4
  import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
4
5
  import { GeometryInputBlock } from "./geometryInputBlock.js";
5
6
  import { Vector2, Vector3, Vector4 } from "../../../Maths/math.vector.js";
7
+ import { PropertyTypeForEdition, editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
8
+ import { NodeGeometryContextualSources } from "../Enums/nodeGeometryContextualSources.js";
6
9
  /**
7
10
  * Block used to get a random number
8
11
  */
@@ -13,6 +16,11 @@ export class RandomBlock extends NodeGeometryBlock {
13
16
  */
14
17
  constructor(name) {
15
18
  super(name);
19
+ this._currentLoopId = -1;
20
+ /**
21
+ * Gets or sets a boolean indicating that this block will generate a new value only once per loop
22
+ */
23
+ this.lockPerLoop = false;
16
24
  this.registerInput("min", NodeGeometryBlockConnectionPointTypes.AutoDetect);
17
25
  this.registerInput("max", NodeGeometryBlockConnectionPointTypes.AutoDetect);
18
26
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
@@ -62,6 +70,7 @@ export class RandomBlock extends NodeGeometryBlock {
62
70
  }
63
71
  _buildBlock() {
64
72
  let func = null;
73
+ this._currentLoopId = -1;
65
74
  switch (this.min.type) {
66
75
  case NodeGeometryBlockConnectionPointTypes.Int:
67
76
  case NodeGeometryBlockConnectionPointTypes.Float: {
@@ -97,8 +106,40 @@ export class RandomBlock extends NodeGeometryBlock {
97
106
  break;
98
107
  }
99
108
  }
100
- this.output._storedFunction = func;
109
+ if (!this.lockPerLoop || !func) {
110
+ this.output._storedFunction = func;
111
+ }
112
+ else {
113
+ this.output._storedFunction = (state) => {
114
+ const loopId = state.getContextualValue(NodeGeometryContextualSources.LoopID);
115
+ if (this._currentLoopId !== loopId) {
116
+ this._currentLoopId = loopId;
117
+ this.output._storedValue = func(state);
118
+ }
119
+ return this.output._storedValue;
120
+ };
121
+ }
122
+ }
123
+ _dumpPropertiesCode() {
124
+ const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockPerLoop = ${this.lockPerLoop ? "true" : "false"};\n`;
125
+ return codeString;
126
+ }
127
+ /**
128
+ * Serializes this block in a JSON representation
129
+ * @returns the serialized block object
130
+ */
131
+ serialize() {
132
+ const serializationObject = super.serialize();
133
+ serializationObject.lockPerLoop = this.lockPerLoop;
134
+ return serializationObject;
135
+ }
136
+ _deserialize(serializationObject) {
137
+ super._deserialize(serializationObject);
138
+ this.lockPerLoop = !!serializationObject.lockPerLoop;
101
139
  }
102
140
  }
141
+ __decorate([
142
+ editableInPropertyPage("Lock per loop", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
143
+ ], RandomBlock.prototype, "lockPerLoop", void 0);
103
144
  RegisterClass("BABYLON.RandomBlock", RandomBlock);
104
145
  //# sourceMappingURL=randomBlock.js.map
@@ -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;AAGvE;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAC9C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE5E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;QAElF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,MAAM,CAAC,CAAC;QAChG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QACl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CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EACvC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAC1C,CAAC;gBACN,CAAC,CAAC;gBACF,MAAM;aACT;SACJ;QAED,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;IACvC,CAAC;CACJ;AAED,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\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\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[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\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 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 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 _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\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 this.output._storedFunction = func;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
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,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,6CAAsC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAQ9C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZR,mBAAc,GAAG,CAAC,CAAC,CAAC;QAC5B;;WAEG;QAEI,gBAAW,GA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C;gBACD,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACpC,CAAC,CAAC;SACL;IACL,CAAC;IAES,mBAAmB;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,kBAAkB,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QACrI,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QAEnD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC;IACzD,CAAC;CACJ;AAnJU;IADN,sBAAsB,CAAC,eAAe,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;gDAC3F;AAqJ/B,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 * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\r\n private _currentLoopId = -1;\r\n /**\r\n * Gets or sets a boolean indicating that this block will generate a new value only once per loop\r\n */\r\n @editableInPropertyPage(\"Lock per loop\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public lockPerLoop = false;\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[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\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 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 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 _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n this._currentLoopId = -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.lockPerLoop || !func) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = (state) => {\r\n const loopId = state.getContextualValue(NodeGeometryContextualSources.LoopID);\r\n if (this._currentLoopId !== loopId) {\r\n this._currentLoopId = loopId;\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 _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockPerLoop = ${this.lockPerLoop ? \"true\" : \"false\"};\\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.lockPerLoop = this.lockPerLoop;\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.lockPerLoop = !!serializationObject.lockPerLoop;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
@@ -163,6 +163,11 @@ export class NodeGeometry {
163
163
  state.buildId = this._buildId;
164
164
  state.verbose = verbose;
165
165
  this.outputBlock.build(state);
166
+ // Special case for debug nodes which are not connected to output
167
+ const debugNodesToProcess = this.attachedBlocks.filter((b) => b.getClassName() === "DebugBlock" && !b._outputs[0].isConnected);
168
+ for (const debugNode of debugNodesToProcess) {
169
+ debugNode.output._storedFunction(state);
170
+ }
166
171
  if (updateBuildId) {
167
172
  this._buildId = NodeGeometry._BuildIdGenerator++;
168
173
  }