@babylonjs/core 7.29.0 → 7.30.1

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 (169) hide show
  1. package/Engines/WebGPU/webgpuCacheBindGroups.js +13 -2
  2. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  3. package/Engines/WebGPU/webgpuCacheSampler.js +2 -3
  4. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  5. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -1
  6. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  7. package/Engines/abstractEngine.js +2 -2
  8. package/Engines/abstractEngine.js.map +1 -1
  9. package/Engines/engine.d.ts +2 -1
  10. package/Engines/nullEngine.d.ts +1 -0
  11. package/Engines/nullEngine.js +1 -0
  12. package/Engines/nullEngine.js.map +1 -1
  13. package/Engines/webgpuEngine.d.ts +4 -0
  14. package/Engines/webgpuEngine.js +1 -3
  15. package/Engines/webgpuEngine.js.map +1 -1
  16. package/Materials/Background/backgroundMaterial.js +1 -11
  17. package/Materials/Background/backgroundMaterial.js.map +1 -1
  18. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +8 -0
  19. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +43 -34
  20. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  21. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.d.ts +32 -0
  22. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +64 -0
  23. package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -0
  24. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.d.ts +48 -0
  25. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +102 -0
  26. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -0
  27. package/Materials/Node/Blocks/GaussianSplatting/index.d.ts +3 -0
  28. package/Materials/Node/Blocks/GaussianSplatting/index.js +4 -0
  29. package/Materials/Node/Blocks/GaussianSplatting/index.js.map +1 -0
  30. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +40 -0
  31. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +96 -0
  32. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -0
  33. package/Materials/Node/Blocks/Input/inputBlock.js +6 -0
  34. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  35. package/Materials/Node/Blocks/index.d.ts +1 -0
  36. package/Materials/Node/Blocks/index.js +1 -0
  37. package/Materials/Node/Blocks/index.js.map +1 -1
  38. package/Materials/Node/Enums/nodeMaterialModes.d.ts +3 -1
  39. package/Materials/Node/Enums/nodeMaterialModes.js +2 -0
  40. package/Materials/Node/Enums/nodeMaterialModes.js.map +1 -1
  41. package/Materials/Node/index.d.ts +1 -0
  42. package/Materials/Node/index.js +1 -0
  43. package/Materials/Node/index.js.map +1 -1
  44. package/Materials/Node/nodeMaterialDefault.d.ts +6 -0
  45. package/Materials/Node/nodeMaterialDefault.js +53 -0
  46. package/Materials/Node/nodeMaterialDefault.js.map +1 -0
  47. package/Materials/PBR/pbrBaseMaterial.js +1 -11
  48. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  49. package/Materials/Textures/rawTexture3D.d.ts +12 -0
  50. package/Materials/Textures/rawTexture3D.js +18 -0
  51. package/Materials/Textures/rawTexture3D.js.map +1 -1
  52. package/Materials/Textures/texture.js +7 -3
  53. package/Materials/Textures/texture.js.map +1 -1
  54. package/Materials/Textures/textureSampler.d.ts +1 -1
  55. package/Materials/Textures/textureSampler.js.map +1 -1
  56. package/Materials/effect.d.ts +11 -0
  57. package/Materials/effect.js +20 -0
  58. package/Materials/effect.js.map +1 -1
  59. package/Materials/material.d.ts +5 -1
  60. package/Materials/material.js +19 -1
  61. package/Materials/material.js.map +1 -1
  62. package/Materials/materialPluginBase.d.ts +46 -46
  63. package/Materials/materialPluginBase.js +46 -60
  64. package/Materials/materialPluginBase.js.map +1 -1
  65. package/Materials/materialPluginManager.js +2 -2
  66. package/Materials/materialPluginManager.js.map +1 -1
  67. package/Materials/pushMaterial.d.ts +1 -1
  68. package/Materials/pushMaterial.js +2 -2
  69. package/Materials/pushMaterial.js.map +1 -1
  70. package/Materials/standardMaterial.js +1 -11
  71. package/Materials/standardMaterial.js.map +1 -1
  72. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +11 -0
  73. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +72 -37
  74. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  75. package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +76 -0
  76. package/Meshes/Node/Blocks/Set/aggregatorBlock.js +210 -0
  77. package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -0
  78. package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +91 -0
  79. package/Meshes/Node/Blocks/Set/latticeBlock.js +194 -0
  80. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -0
  81. package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +6 -0
  82. package/Meshes/Node/Blocks/booleanGeometryBlock.js +16 -4
  83. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
  84. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +8 -0
  85. package/Meshes/Node/Blocks/geometryClampBlock.js +22 -6
  86. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  87. package/Meshes/Node/Blocks/geometryInputBlock.js +2 -0
  88. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  89. package/Meshes/Node/Blocks/geometryInterceptorBlock.d.ts +5 -0
  90. package/Meshes/Node/Blocks/geometryInterceptorBlock.js +5 -1
  91. package/Meshes/Node/Blocks/geometryInterceptorBlock.js.map +1 -1
  92. package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +6 -0
  93. package/Meshes/Node/Blocks/geometryTransformBlock.js +14 -2
  94. package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
  95. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +5 -1
  96. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +4 -0
  97. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  98. package/Meshes/Node/index.d.ts +2 -0
  99. package/Meshes/Node/index.js +2 -0
  100. package/Meshes/Node/index.js.map +1 -1
  101. package/Meshes/Node/nodeGeometry.d.ts +1 -1
  102. package/Meshes/Node/nodeGeometry.js +14 -1
  103. package/Meshes/Node/nodeGeometry.js.map +1 -1
  104. package/Meshes/Node/nodeGeometryBlock.d.ts +4 -0
  105. package/Meshes/Node/nodeGeometryBlock.js +6 -0
  106. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  107. package/Meshes/Node/nodeGeometryBuildState.js +12 -0
  108. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  109. package/Meshes/csg.d.ts +1 -0
  110. package/Meshes/csg.js +1 -0
  111. package/Meshes/csg.js.map +1 -1
  112. package/Meshes/csg2.d.ts +126 -0
  113. package/Meshes/csg2.js +350 -0
  114. package/Meshes/csg2.js.map +1 -0
  115. package/Meshes/index.d.ts +2 -0
  116. package/Meshes/index.js +2 -0
  117. package/Meshes/index.js.map +1 -1
  118. package/Meshes/lattice.d.ts +18 -1
  119. package/Meshes/lattice.js +34 -6
  120. package/Meshes/lattice.js.map +1 -1
  121. package/Meshes/lattice.material.d.ts +82 -0
  122. package/Meshes/lattice.material.js +259 -0
  123. package/Meshes/lattice.material.js.map +1 -0
  124. package/Meshes/mesh.js +3 -1
  125. package/Meshes/mesh.js.map +1 -1
  126. package/Meshes/mesh.vertexData.d.ts +66 -1
  127. package/Meshes/mesh.vertexData.js.map +1 -1
  128. package/Misc/dumpTools.js +1 -0
  129. package/Misc/dumpTools.js.map +1 -1
  130. package/Misc/screenshotTools.js +0 -3
  131. package/Misc/screenshotTools.js.map +1 -1
  132. package/Misc/tools.d.ts +2 -1
  133. package/Misc/tools.internals.d.ts +13 -0
  134. package/Misc/tools.internals.js +48 -0
  135. package/Misc/tools.internals.js.map +1 -0
  136. package/Misc/tools.js +13 -4
  137. package/Misc/tools.js.map +1 -1
  138. package/Morph/morphTarget.js +1 -0
  139. package/Morph/morphTarget.js.map +1 -1
  140. package/Shaders/ShadersInclude/gaussianSplatting.d.ts +5 -0
  141. package/Shaders/ShadersInclude/gaussianSplatting.js +33 -0
  142. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -0
  143. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.d.ts +7 -0
  144. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.js +19 -0
  145. package/Shaders/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -0
  146. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +1 -1
  147. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  148. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
  149. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  150. package/Shaders/gaussianSplatting.fragment.d.ts +1 -2
  151. package/Shaders/gaussianSplatting.fragment.js +5 -10
  152. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  153. package/Shaders/gaussianSplatting.vertex.d.ts +1 -0
  154. package/Shaders/gaussianSplatting.vertex.js +4 -21
  155. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  156. package/ShadersWGSL/default.fragment.js +1 -1
  157. package/ShadersWGSL/default.fragment.js.map +1 -1
  158. package/ShadersWGSL/pbr.fragment.js +1 -1
  159. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  160. package/Sprites/spriteManager.d.ts +10 -1
  161. package/Sprites/spriteManager.js +3 -2
  162. package/Sprites/spriteManager.js.map +1 -1
  163. package/Sprites/spritePackedManager.d.ts +6 -1
  164. package/Sprites/spritePackedManager.js +6 -2
  165. package/Sprites/spritePackedManager.js.map +1 -1
  166. package/Sprites/spriteRenderer.d.ts +16 -3
  167. package/Sprites/spriteRenderer.js +5 -3
  168. package/Sprites/spriteRenderer.js.map +1 -1
  169. package/package.json +1 -1
@@ -0,0 +1,210 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
2
+ import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
3
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
4
+ import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
5
+ import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
6
+ import { Vector2, Vector3, Vector4 } from "../../../../Maths/math.vector.js";
7
+ /**
8
+ * Conditions supported by the condition block
9
+ */
10
+ export var Aggregations;
11
+ (function (Aggregations) {
12
+ /** Max */
13
+ Aggregations[Aggregations["Max"] = 0] = "Max";
14
+ /** Min */
15
+ Aggregations[Aggregations["Min"] = 1] = "Min";
16
+ /** Sum */
17
+ Aggregations[Aggregations["Sum"] = 2] = "Sum";
18
+ })(Aggregations || (Aggregations = {}));
19
+ /**
20
+ * Block used to extract a valuefrom a geometry
21
+ */
22
+ export class AggregatorBlock extends NodeGeometryBlock {
23
+ /**
24
+ * Create a new SetPositionsBlock
25
+ * @param name defines the block name
26
+ */
27
+ constructor(name) {
28
+ super(name);
29
+ /**
30
+ * Gets or sets the test used by the block
31
+ */
32
+ this.aggregation = Aggregations.Sum;
33
+ /**
34
+ * Gets or sets a boolean indicating that this block can evaluate context
35
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
36
+ */
37
+ this.evaluateContext = true;
38
+ this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
39
+ this.registerInput("source", NodeGeometryBlockConnectionPointTypes.AutoDetect);
40
+ this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
41
+ this._outputs[0]._typeConnectionSource = this._inputs[1];
42
+ }
43
+ /**
44
+ * Gets the current index in the current flow
45
+ * @returns the current index
46
+ */
47
+ getExecutionIndex() {
48
+ return this._currentIndex;
49
+ }
50
+ /**
51
+ * Gets the current loop index in the current flow
52
+ * @returns the current loop index
53
+ */
54
+ getExecutionLoopIndex() {
55
+ return this._currentIndex;
56
+ }
57
+ /**
58
+ * Gets the current face index in the current flow
59
+ * @returns the current face index
60
+ */
61
+ getExecutionFaceIndex() {
62
+ return 0;
63
+ }
64
+ /**
65
+ * Gets the current class name
66
+ * @returns the class name
67
+ */
68
+ getClassName() {
69
+ return "AggregatorBlock";
70
+ }
71
+ /**
72
+ * Gets the geometry input component
73
+ */
74
+ get geometry() {
75
+ return this._inputs[0];
76
+ }
77
+ /**
78
+ * Gets the source input component
79
+ */
80
+ get source() {
81
+ return this._inputs[1];
82
+ }
83
+ /**
84
+ * Gets the geometry output component
85
+ */
86
+ get output() {
87
+ return this._outputs[0];
88
+ }
89
+ _buildBlock(state) {
90
+ const func = (state) => {
91
+ state.pushExecutionContext(this);
92
+ this._vertexData = this.geometry.getConnectedValue(state);
93
+ state.pushGeometryContext(this._vertexData);
94
+ if (!this._vertexData || !this._vertexData.positions || !this.source.isConnected) {
95
+ state.restoreGeometryContext();
96
+ state.restoreExecutionContext();
97
+ this.output._storedValue = null;
98
+ return;
99
+ }
100
+ // Processing
101
+ const vertexCount = this._vertexData.positions.length / 3;
102
+ const context = [];
103
+ for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {
104
+ context.push(this.source.getConnectedValue(state));
105
+ }
106
+ // Aggregation
107
+ let func = null;
108
+ switch (this.aggregation) {
109
+ case Aggregations.Max: {
110
+ func = (a, b) => Math.max(a, b);
111
+ break;
112
+ }
113
+ case Aggregations.Min: {
114
+ func = (a, b) => Math.min(a, b);
115
+ break;
116
+ }
117
+ case Aggregations.Sum: {
118
+ func = (a, b) => a + b;
119
+ break;
120
+ }
121
+ }
122
+ if (!func) {
123
+ state.restoreGeometryContext();
124
+ state.restoreExecutionContext();
125
+ this.output._storedFunction = null;
126
+ this.output._storedValue = null;
127
+ return;
128
+ }
129
+ let returnValue;
130
+ switch (this.source.type) {
131
+ case NodeGeometryBlockConnectionPointTypes.Int:
132
+ case NodeGeometryBlockConnectionPointTypes.Float: {
133
+ returnValue = context.reduce(func);
134
+ break;
135
+ }
136
+ case NodeGeometryBlockConnectionPointTypes.Vector2: {
137
+ const x = context.map((v) => v.x).reduce(func);
138
+ const y = context.map((v) => v.y).reduce(func);
139
+ returnValue = new Vector2(x, y);
140
+ break;
141
+ }
142
+ case NodeGeometryBlockConnectionPointTypes.Vector3: {
143
+ const x = context.map((v) => v.x).reduce(func);
144
+ const y = context.map((v) => v.y).reduce(func);
145
+ const z = context.map((v) => v.z).reduce(func);
146
+ returnValue = new Vector3(x, y, z);
147
+ break;
148
+ }
149
+ case NodeGeometryBlockConnectionPointTypes.Vector4: {
150
+ const x = context.map((v) => v.x).reduce(func);
151
+ const y = context.map((v) => v.y).reduce(func);
152
+ const z = context.map((v) => v.z).reduce(func);
153
+ const w = context.map((v) => v.w).reduce(func);
154
+ returnValue = new Vector4(x, y, z, w);
155
+ break;
156
+ }
157
+ }
158
+ // Storage
159
+ state.restoreGeometryContext();
160
+ state.restoreExecutionContext();
161
+ return returnValue;
162
+ };
163
+ if (this.evaluateContext) {
164
+ this.output._storedFunction = func;
165
+ }
166
+ else {
167
+ this.output._storedFunction = null;
168
+ this.output._storedValue = func(state);
169
+ }
170
+ }
171
+ _dumpPropertiesCode() {
172
+ let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
173
+ codeString += `${this._codeVariableName}.aggregation = BABYLON.Aggregations.${Aggregations[this.aggregation]};\n`;
174
+ return codeString;
175
+ }
176
+ /**
177
+ * Serializes this block in a JSON representation
178
+ * @returns the serialized block object
179
+ */
180
+ serialize() {
181
+ const serializationObject = super.serialize();
182
+ serializationObject.evaluateContext = this.evaluateContext;
183
+ serializationObject.aggregation = this.aggregation;
184
+ return serializationObject;
185
+ }
186
+ _deserialize(serializationObject) {
187
+ super._deserialize(serializationObject);
188
+ if (serializationObject.evaluateContext !== undefined) {
189
+ this.evaluateContext = serializationObject.evaluateContext;
190
+ }
191
+ if (serializationObject.aggregation !== undefined) {
192
+ this.aggregation = serializationObject.aggregation;
193
+ }
194
+ }
195
+ }
196
+ __decorate([
197
+ editableInPropertyPage("Aggregation", 4 /* PropertyTypeForEdition.List */, "ADVANCED", {
198
+ notifiers: { rebuild: true },
199
+ options: [
200
+ { label: "Max", value: Aggregations.Max },
201
+ { label: "Min", value: Aggregations.Min },
202
+ { label: "Sum", value: Aggregations.Sum },
203
+ ],
204
+ })
205
+ ], AggregatorBlock.prototype, "aggregation", void 0);
206
+ __decorate([
207
+ editableInPropertyPage("Evaluate context", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { rebuild: true } })
208
+ ], AggregatorBlock.prototype, "evaluateContext", void 0);
209
+ RegisterClass("BABYLON.AggregatorBlock", AggregatorBlock);
210
+ //# sourceMappingURL=aggregatorBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregatorBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/aggregatorBlock.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;AAIrG,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAC/F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAGnE;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACpB,UAAU;IACV,6CAAG,CAAA;IACH,UAAU;IACV,6CAAG,CAAA;IACH,UAAU;IACV,6CAAG,CAAA;AACP,CAAC,EAPW,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+B,UAAU,EAAE;QAC5E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE;YACzC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE;YACzC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE;SAC5C;KACJ,CAAC;oDACoC;AAO/B;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;wDAC3F;AAiMlC,aAAa,CAAC,yBAAyB,EAAE,eAAe,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 type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Conditions supported by the condition block\r\n */\r\nexport enum Aggregations {\r\n /** Max */\r\n Max,\r\n /** Min */\r\n Min,\r\n /** Sum */\r\n Sum,\r\n}\r\n\r\n/**\r\n * Block used to extract a valuefrom a geometry\r\n */\r\nexport class AggregatorBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets the test used by the block\r\n */\r\n @editableInPropertyPage(\"Aggregation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Max\", value: Aggregations.Max },\r\n { label: \"Min\", value: Aggregations.Min },\r\n { label: \"Sum\", value: Aggregations.Sum },\r\n ],\r\n })\r\n public aggregation = Aggregations.Sum;\r\n\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 * Create a new SetPositionsBlock\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.registerInput(\"source\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n this._outputs[0]._typeConnectionSource = this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\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 override getClassName() {\r\n return \"AggregatorBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input 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 source input component\r\n */\r\n public get source(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n state.pushGeometryContext(this._vertexData);\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this.source.isConnected) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n const context: any[] = [];\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n context.push(this.source.getConnectedValue(state));\r\n }\r\n\r\n // Aggregation\r\n let func: Nullable<(a: number, b: number) => number> = null;\r\n\r\n switch (this.aggregation) {\r\n case Aggregations.Max: {\r\n func = (a: number, b: number) => Math.max(a, b);\r\n break;\r\n }\r\n case Aggregations.Min: {\r\n func = (a: number, b: number) => Math.min(a, b);\r\n break;\r\n }\r\n case Aggregations.Sum: {\r\n func = (a: number, b: number) => a + b;\r\n break;\r\n }\r\n }\r\n\r\n if (!func) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n let returnValue: any;\r\n\r\n switch (this.source.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n returnValue = (context as number[]).reduce(func!);\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n const x = (context as Vector2[]).map((v) => v.x).reduce(func!);\r\n const y = (context as Vector2[]).map((v) => v.y).reduce(func!);\r\n returnValue = new Vector2(x, y);\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n const x = (context as Vector3[]).map((v) => v.x).reduce(func!);\r\n const y = (context as Vector3[]).map((v) => v.y).reduce(func!);\r\n const z = (context as Vector3[]).map((v) => v.z).reduce(func!);\r\n returnValue = new Vector3(x, y, z);\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n const x = (context as Vector4[]).map((v) => v.x).reduce(func!);\r\n const y = (context as Vector4[]).map((v) => v.y).reduce(func!);\r\n const z = (context as Vector4[]).map((v) => v.z).reduce(func!);\r\n const w = (context as Vector4[]).map((v) => v.w).reduce(func!);\r\n returnValue = new Vector4(x, y, z, w);\r\n break;\r\n }\r\n }\r\n\r\n // Storage\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n return returnValue;\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 override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.aggregation = BABYLON.Aggregations.${Aggregations[this.aggregation]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.aggregation = this.aggregation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n if (serializationObject.aggregation !== undefined) {\r\n this.aggregation = serializationObject.aggregation;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AggregatorBlock\", AggregatorBlock);\r\n"]}
@@ -0,0 +1,91 @@
1
+ import { NodeGeometryBlock } from "../../nodeGeometryBlock";
2
+ import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnectionPoint";
3
+ import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
4
+ import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
5
+ import { Vector3 } from "../../../../Maths/math.vector";
6
+ /**
7
+ * Block used to apply Lattice on geometry
8
+ */
9
+ export declare class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
10
+ private _vertexData;
11
+ private _currentIndexX;
12
+ private _currentIndexY;
13
+ private _currentIndexZ;
14
+ private _lattice;
15
+ private _indexVector3;
16
+ private _currentControl;
17
+ /**
18
+ * Gets or sets a boolean indicating that this block can evaluate context
19
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
20
+ */
21
+ evaluateContext: boolean;
22
+ /**
23
+ * Resolution on x axis
24
+ */
25
+ resolutionX: number;
26
+ /**
27
+ * Resolution on y axis
28
+ */
29
+ resolutionY: number;
30
+ /**
31
+ * Resolution on z axis
32
+ */
33
+ resolutionZ: number;
34
+ /**
35
+ * Create a new LatticeBlock
36
+ * @param name defines the block name
37
+ */
38
+ constructor(name: string);
39
+ /**
40
+ * Gets the current index in the current flow
41
+ * @returns the current index
42
+ */
43
+ getExecutionIndex(): number;
44
+ /**
45
+ * Gets the current loop index in the current flow
46
+ * @returns the current loop index
47
+ */
48
+ getExecutionLoopIndex(): number;
49
+ /**
50
+ * Gets the current face index in the current flow
51
+ * @returns the current face index
52
+ */
53
+ getExecutionFaceIndex(): number;
54
+ /**
55
+ * Gets the current class name
56
+ * @returns the class name
57
+ */
58
+ getClassName(): string;
59
+ /**
60
+ * Gets the geometry input component
61
+ */
62
+ get geometry(): NodeGeometryConnectionPoint;
63
+ /**
64
+ * Gets the controls input component
65
+ */
66
+ get controls(): NodeGeometryConnectionPoint;
67
+ /**
68
+ * Gets the geometry output component
69
+ */
70
+ get output(): NodeGeometryConnectionPoint;
71
+ /**
72
+ * Gets the value associated with a contextual positions
73
+ * In this case it will be the current position in the lattice
74
+ * @returns the current position in the lattice
75
+ */
76
+ getOverridePositionsContextualValue(): Vector3;
77
+ /**
78
+ * Gets the value associated with a contextual normals
79
+ * In this case it will be the current control point being processed
80
+ * @returns the current control point being processed
81
+ */
82
+ getOverrideNormalsContextualValue(): Vector3;
83
+ protected _buildBlock(state: NodeGeometryBuildState): void;
84
+ protected _dumpPropertiesCode(): string;
85
+ /**
86
+ * Serializes this block in a JSON representation
87
+ * @returns the serialized block object
88
+ */
89
+ serialize(): any;
90
+ _deserialize(serializationObject: any): void;
91
+ }
@@ -0,0 +1,194 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
2
+ import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
3
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
4
+ import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
5
+ import { Vector3 } from "../../../../Maths/math.vector.js";
6
+ import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
7
+ import { Lattice } from "../../../lattice.js";
8
+ import { extractMinAndMax } from "../../../../Maths/math.functions.js";
9
+ /**
10
+ * Block used to apply Lattice on geometry
11
+ */
12
+ export class LatticeBlock extends NodeGeometryBlock {
13
+ /**
14
+ * Create a new LatticeBlock
15
+ * @param name defines the block name
16
+ */
17
+ constructor(name) {
18
+ super(name);
19
+ this._indexVector3 = new Vector3();
20
+ this._currentControl = new Vector3();
21
+ /**
22
+ * Gets or sets a boolean indicating that this block can evaluate context
23
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
24
+ */
25
+ this.evaluateContext = true;
26
+ /**
27
+ * Resolution on x axis
28
+ */
29
+ this.resolutionX = 3;
30
+ /**
31
+ * Resolution on y axis
32
+ */
33
+ this.resolutionY = 3;
34
+ /**
35
+ * Resolution on z axis
36
+ */
37
+ this.resolutionZ = 3;
38
+ this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
39
+ this.registerInput("controls", NodeGeometryBlockConnectionPointTypes.Vector3);
40
+ this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
41
+ }
42
+ /**
43
+ * Gets the current index in the current flow
44
+ * @returns the current index
45
+ */
46
+ getExecutionIndex() {
47
+ return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);
48
+ }
49
+ /**
50
+ * Gets the current loop index in the current flow
51
+ * @returns the current loop index
52
+ */
53
+ getExecutionLoopIndex() {
54
+ return this.getExecutionIndex();
55
+ }
56
+ /**
57
+ * Gets the current face index in the current flow
58
+ * @returns the current face index
59
+ */
60
+ getExecutionFaceIndex() {
61
+ return 0;
62
+ }
63
+ /**
64
+ * Gets the current class name
65
+ * @returns the class name
66
+ */
67
+ getClassName() {
68
+ return "LatticeBlock";
69
+ }
70
+ /**
71
+ * Gets the geometry input component
72
+ */
73
+ get geometry() {
74
+ return this._inputs[0];
75
+ }
76
+ /**
77
+ * Gets the controls input component
78
+ */
79
+ get controls() {
80
+ return this._inputs[1];
81
+ }
82
+ /**
83
+ * Gets the geometry output component
84
+ */
85
+ get output() {
86
+ return this._outputs[0];
87
+ }
88
+ /**
89
+ * Gets the value associated with a contextual positions
90
+ * In this case it will be the current position in the lattice
91
+ * @returns the current position in the lattice
92
+ */
93
+ getOverridePositionsContextualValue() {
94
+ return this._indexVector3;
95
+ }
96
+ /**
97
+ * Gets the value associated with a contextual normals
98
+ * In this case it will be the current control point being processed
99
+ * @returns the current control point being processed
100
+ */
101
+ getOverrideNormalsContextualValue() {
102
+ return this._currentControl;
103
+ }
104
+ _buildBlock(state) {
105
+ const func = (state) => {
106
+ state.pushExecutionContext(this);
107
+ this._vertexData = this.geometry.getConnectedValue(state);
108
+ if (this._vertexData) {
109
+ this._vertexData = this._vertexData.clone(); // Preserve source data
110
+ }
111
+ if (!this._vertexData || !this._vertexData.positions) {
112
+ state.restoreExecutionContext();
113
+ this.output._storedValue = null;
114
+ return;
115
+ }
116
+ const positions = this._vertexData.positions;
117
+ const boundingInfo = extractMinAndMax(positions, 0, positions.length / 3);
118
+ // Building the lattice
119
+ this._lattice = new Lattice({
120
+ resolutionX: this.resolutionX,
121
+ resolutionY: this.resolutionY,
122
+ resolutionZ: this.resolutionZ,
123
+ size: boundingInfo.maximum.subtract(boundingInfo.minimum),
124
+ });
125
+ for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {
126
+ for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {
127
+ for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {
128
+ this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);
129
+ const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];
130
+ this._currentControl.copyFrom(latticeControl);
131
+ const tempVector3 = this.controls.getConnectedValue(state);
132
+ if (tempVector3) {
133
+ latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ // Apply lattice
139
+ this._lattice.deform(positions);
140
+ // Storage
141
+ state.restoreExecutionContext();
142
+ return this._vertexData;
143
+ };
144
+ if (this.evaluateContext) {
145
+ this.output._storedFunction = func;
146
+ }
147
+ else {
148
+ this.output._storedFunction = null;
149
+ this.output._storedValue = func(state);
150
+ }
151
+ }
152
+ _dumpPropertiesCode() {
153
+ let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
154
+ codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\n`;
155
+ codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\n`;
156
+ codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\n`;
157
+ return codeString;
158
+ }
159
+ /**
160
+ * Serializes this block in a JSON representation
161
+ * @returns the serialized block object
162
+ */
163
+ serialize() {
164
+ const serializationObject = super.serialize();
165
+ serializationObject.evaluateContext = this.evaluateContext;
166
+ serializationObject.resolutionX = this.resolutionX;
167
+ serializationObject.resolutionY = this.resolutionY;
168
+ serializationObject.resolutionZ = this.resolutionZ;
169
+ return serializationObject;
170
+ }
171
+ _deserialize(serializationObject) {
172
+ super._deserialize(serializationObject);
173
+ if (serializationObject.evaluateContext !== undefined) {
174
+ this.evaluateContext = serializationObject.evaluateContext;
175
+ this.resolutionX = serializationObject.resolutionX;
176
+ this.resolutionY = serializationObject.resolutionY;
177
+ this.resolutionZ = serializationObject.resolutionZ;
178
+ }
179
+ }
180
+ }
181
+ __decorate([
182
+ editableInPropertyPage("Evaluate context", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { rebuild: true } })
183
+ ], LatticeBlock.prototype, "evaluateContext", void 0);
184
+ __decorate([
185
+ editableInPropertyPage("resolutionX", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
186
+ ], LatticeBlock.prototype, "resolutionX", void 0);
187
+ __decorate([
188
+ editableInPropertyPage("resolutionY", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
189
+ ], LatticeBlock.prototype, "resolutionY", void 0);
190
+ __decorate([
191
+ editableInPropertyPage("resolutionZ", 2 /* PropertyTypeForEdition.Int */, "ADVANCED", { notifiers: { rebuild: true }, min: 1, max: 10 })
192
+ ], LatticeBlock.prototype, "resolutionZ", void 0);
193
+ RegisterClass("BABYLON.LatticeBlock", LatticeBlock);
194
+ //# sourceMappingURL=latticeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latticeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/latticeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aA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AC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;YAC3D,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;SACtD;IACL,CAAC;CACJ;AAnMU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;qDAC3F;AAMvB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1G;AAmL3B,aAAa,CAAC,sBAAsB,EAAE,YAAY,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 type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Lattice } from \"core/Meshes/lattice\";\r\nimport { extractMinAndMax } from \"core/Maths/math.functions\";\r\n\r\n/**\r\n * Block used to apply Lattice on geometry\r\n */\r\nexport class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndexX: number;\r\n private _currentIndexY: number;\r\n private _currentIndexZ: number;\r\n private _lattice: Lattice;\r\n private _indexVector3 = new Vector3();\r\n private _currentControl = new Vector3();\r\n\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 * Resolution on x axis\r\n */\r\n @editableInPropertyPage(\"resolutionX\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionX = 3;\r\n\r\n /**\r\n * Resolution on y axis\r\n */\r\n @editableInPropertyPage(\"resolutionY\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionY = 3;\r\n\r\n /**\r\n * Resolution on z axis\r\n */\r\n @editableInPropertyPage(\"resolutionZ\", PropertyTypeForEdition.Int, \"ADVANCED\", { notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionZ = 3;\r\n\r\n /**\r\n * Create a new LatticeBlock\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.registerInput(\"controls\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this.getExecutionIndex();\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\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 override getClassName() {\r\n return \"LatticeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input 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 controls input component\r\n */\r\n public get controls(): 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 /**\r\n * Gets the value associated with a contextual positions\r\n * In this case it will be the current position in the lattice\r\n * @returns the current position in the lattice\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._indexVector3;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * In this case it will be the current control point being processed\r\n * @returns the current control point being processed\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n return this._currentControl;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n const positions = this._vertexData.positions;\r\n const boundingInfo = extractMinAndMax(positions!, 0, positions!.length / 3);\r\n\r\n // Building the lattice\r\n this._lattice = new Lattice({\r\n resolutionX: this.resolutionX,\r\n resolutionY: this.resolutionY,\r\n resolutionZ: this.resolutionZ,\r\n size: boundingInfo.maximum.subtract(boundingInfo.minimum),\r\n });\r\n\r\n for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {\r\n for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {\r\n for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {\r\n this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);\r\n const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];\r\n this._currentControl.copyFrom(latticeControl);\r\n const tempVector3 = this.controls.getConnectedValue(state) as Vector3;\r\n\r\n if (tempVector3) {\r\n latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Apply lattice\r\n this._lattice.deform(positions);\r\n\r\n // Storage\r\n state.restoreExecutionContext();\r\n return this._vertexData;\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 override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n\r\n codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.resolutionX = this.resolutionX;\r\n serializationObject.resolutionY = this.resolutionY;\r\n serializationObject.resolutionZ = this.resolutionZ;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.resolutionX = serializationObject.resolutionX;\r\n this.resolutionY = serializationObject.resolutionY;\r\n this.resolutionZ = serializationObject.resolutionZ;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LatticeBlock\", LatticeBlock);\r\n"]}
@@ -1,6 +1,7 @@
1
1
  import { NodeGeometryBlock } from "../nodeGeometryBlock";
2
2
  import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
3
3
  import type { NodeGeometryBuildState } from "../nodeGeometryBuildState";
4
+ import type { Nullable } from "../../../types.js";
4
5
  /**
5
6
  * Operations supported by the boolean block
6
7
  */
@@ -25,6 +26,11 @@ export declare class BooleanGeometryBlock extends NodeGeometryBlock {
25
26
  * Gets or sets the operation applied by the block
26
27
  */
27
28
  operation: BooleanGeometryOperations;
29
+ private _csg2LoadingPromise;
30
+ /**
31
+ * @internal
32
+ */
33
+ get _isReadyState(): Nullable<Promise<void>>;
28
34
  /**
29
35
  * Create a new BooleanGeometryBlock
30
36
  * @param name defines the block name
@@ -3,7 +3,7 @@ import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
3
3
  import { RegisterClass } from "../../../Misc/typeStore.js";
4
4
  import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
5
5
  import { editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
6
- import { CSG } from "../../csg.js";
6
+ import { CSG2, InitializeCSG2Async, IsCSG2Ready } from "../../csg2.js";
7
7
  /**
8
8
  * Operations supported by the boolean block
9
9
  */
@@ -20,6 +20,18 @@ export var BooleanGeometryOperations;
20
20
  * Block used to apply a boolean operation between 2 geometries
21
21
  */
22
22
  export class BooleanGeometryBlock extends NodeGeometryBlock {
23
+ /**
24
+ * @internal
25
+ */
26
+ get _isReadyState() {
27
+ if (IsCSG2Ready()) {
28
+ return null;
29
+ }
30
+ if (!this._csg2LoadingPromise) {
31
+ this._csg2LoadingPromise = InitializeCSG2Async();
32
+ }
33
+ return this._csg2LoadingPromise;
34
+ }
23
35
  /**
24
36
  * Create a new BooleanGeometryBlock
25
37
  * @param name defines the block name
@@ -91,8 +103,8 @@ export class BooleanGeometryBlock extends NodeGeometryBlock {
91
103
  if (!vertexData1.colors && vertexData0.colors) {
92
104
  vertexData1.colors = new Array(vertexCount * 4);
93
105
  }
94
- const CSG0 = CSG.FromVertexData(vertexData0);
95
- const CSG1 = CSG.FromVertexData(vertexData1);
106
+ const CSG0 = CSG2.FromVertexData(vertexData0);
107
+ const CSG1 = CSG2.FromVertexData(vertexData1);
96
108
  let boolCSG;
97
109
  switch (this.operation) {
98
110
  case BooleanGeometryOperations.Intersect:
@@ -102,7 +114,7 @@ export class BooleanGeometryBlock extends NodeGeometryBlock {
102
114
  boolCSG = CSG0.subtract(CSG1);
103
115
  break;
104
116
  case BooleanGeometryOperations.Union:
105
- boolCSG = CSG0.union(CSG1);
117
+ boolCSG = CSG0.add(CSG1);
106
118
  break;
107
119
  }
108
120
  return boolCSG.toVertexData();