@babylonjs/core 6.16.0 → 6.16.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.
- package/Bones/boneIKController.js +1 -0
- package/Bones/boneIKController.js.map +1 -1
- package/Debug/axesViewer.js +3 -3
- package/Debug/axesViewer.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +2 -1
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +13 -5
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +7 -3
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -1
- package/Materials/Node/nodeMaterial.js +6 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/greasedLinePluginMaterial.d.ts +96 -4
- package/Materials/greasedLinePluginMaterial.js +15 -6
- package/Materials/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/greasedLineSimpleMaterial.d.ts +228 -0
- package/Materials/greasedLineSimpleMaterial.js +435 -0
- package/Materials/greasedLineSimpleMaterial.js.map +1 -0
- package/Materials/material.decalMapConfiguration.js +2 -0
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.d.ts +66 -17
- package/Materials/meshDebugPluginMaterial.js +65 -75
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +3 -2
- package/Meshes/Builders/greasedLineBuilder.js +26 -15
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/textBuilder.d.ts +6 -0
- package/Meshes/Builders/textBuilder.js +5 -0
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +2 -2
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +9 -3
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.js +2 -2
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +3 -3
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +4 -4
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/nullBlock.d.ts +22 -0
- package/Meshes/Node/Blocks/Sources/nullBlock.js +34 -0
- package/Meshes/Node/Blocks/Sources/nullBlock.js.map +1 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -2
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +9 -6
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/debugBlock.js +1 -1
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +33 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +43 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +118 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryOutputBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryOutputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +8 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.js +20 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +4 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/{IntFloatConverterBlock.js → intFloatConverterBlock.js} +1 -1
- package/Meshes/Node/Blocks/{IntFloatConverterBlock.js.map → intFloatConverterBlock.js.map} +1 -1
- package/Meshes/Node/Blocks/mathBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +6 -2
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.js +2 -2
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/normalizeVectorBlock.d.ts +1 -1
- package/Meshes/Node/Blocks/normalizeVectorBlock.js +1 -1
- package/Meshes/Node/Blocks/normalizeVectorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.d.ts +2 -2
- package/Meshes/Node/Blocks/randomBlock.js +7 -2
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/Node/Blocks/vectorConverterBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/vectorConverterBlock.js +35 -7
- package/Meshes/Node/Blocks/vectorConverterBlock.js.map +1 -1
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.d.ts +5 -5
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js +5 -5
- package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js.map +1 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +1 -3
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +0 -2
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.d.ts +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.js.map +1 -1
- package/Meshes/Node/index.d.ts +3 -1
- package/Meshes/Node/index.js +3 -1
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometry.d.ts +3 -2
- package/Meshes/Node/nodeGeometry.js +10 -9
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.d.ts +7 -1
- package/Meshes/Node/nodeGeometryBlock.js +26 -6
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.d.ts +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +3 -3
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/greasedLineMesh.d.ts +4 -2
- package/Meshes/greasedLineMesh.js +26 -2
- package/Meshes/greasedLineMesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -1
- package/Misc/greasedLineTools.js +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Shaders/greasedLine.fragment.d.ts +5 -0
- package/Shaders/greasedLine.fragment.js +16 -0
- package/Shaders/greasedLine.fragment.js.map +1 -0
- package/Shaders/greasedLine.vertex.d.ts +5 -0
- package/Shaders/greasedLine.vertex.js +19 -0
- package/Shaders/greasedLine.vertex.js.map +1 -0
- package/package.json +1 -1
- /package/Meshes/Node/Blocks/{IntFloatConverterBlock.d.ts → intFloatConverterBlock.d.ts} +0 -0
|
@@ -138,6 +138,7 @@ export class GeometryInputBlock extends NodeGeometryBlock {
|
|
|
138
138
|
* Set the input block to its default value (based on its type)
|
|
139
139
|
*/
|
|
140
140
|
setDefaultValue() {
|
|
141
|
+
this.contextualValue = NodeGeometryContextualSources.None;
|
|
141
142
|
switch (this.type) {
|
|
142
143
|
case NodeGeometryBlockConnectionPointTypes.Int:
|
|
143
144
|
case NodeGeometryBlockConnectionPointTypes.Float:
|
|
@@ -174,6 +175,37 @@ export class GeometryInputBlock extends NodeGeometryBlock {
|
|
|
174
175
|
this.onValueChangedObservable.clear();
|
|
175
176
|
super.dispose();
|
|
176
177
|
}
|
|
178
|
+
_dumpPropertiesCode() {
|
|
179
|
+
const variableName = this._codeVariableName;
|
|
180
|
+
if (this.isContextual) {
|
|
181
|
+
return (super._dumpPropertiesCode() + `${variableName}.contextualValue = BABYLON.NodeGeometryContextualSources.${NodeGeometryContextualSources[this._contextualSource]};\n`);
|
|
182
|
+
}
|
|
183
|
+
const codes = [];
|
|
184
|
+
let valueString = "";
|
|
185
|
+
switch (this.type) {
|
|
186
|
+
case NodeGeometryBlockConnectionPointTypes.Float:
|
|
187
|
+
case NodeGeometryBlockConnectionPointTypes.Int:
|
|
188
|
+
valueString = `${this.value}`;
|
|
189
|
+
break;
|
|
190
|
+
case NodeGeometryBlockConnectionPointTypes.Vector2:
|
|
191
|
+
valueString = `new BABYLON.Vector2(${this.value.x}, ${this.value.y})`;
|
|
192
|
+
break;
|
|
193
|
+
case NodeGeometryBlockConnectionPointTypes.Vector3:
|
|
194
|
+
valueString = `new BABYLON.Vector3(${this.value.x}, ${this.value.y}, ${this.value.z})`;
|
|
195
|
+
break;
|
|
196
|
+
case NodeGeometryBlockConnectionPointTypes.Vector4:
|
|
197
|
+
valueString = `new BABYLON.Vector4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
// Common Property "Value"
|
|
201
|
+
codes.push(`${variableName}.value = ${valueString}`);
|
|
202
|
+
// Float-Value-Specific Properties
|
|
203
|
+
if (this.type === NodeGeometryBlockConnectionPointTypes.Float || this.type === NodeGeometryBlockConnectionPointTypes.Int) {
|
|
204
|
+
codes.push(`${variableName}.min = ${this.min}`, `${variableName}.max = ${this.max}`);
|
|
205
|
+
}
|
|
206
|
+
codes.push("");
|
|
207
|
+
return super._dumpPropertiesCode() + codes.join(";\n");
|
|
208
|
+
}
|
|
177
209
|
serialize() {
|
|
178
210
|
const serializationObject = super.serialize();
|
|
179
211
|
serializationObject.type = this.type;
|
|
@@ -181,7 +213,7 @@ export class GeometryInputBlock extends NodeGeometryBlock {
|
|
|
181
213
|
serializationObject.min = this.min;
|
|
182
214
|
serializationObject.max = this.max;
|
|
183
215
|
serializationObject.groupInInspector = this.groupInInspector;
|
|
184
|
-
if (this._storedValue
|
|
216
|
+
if (this._storedValue !== null && !this.isContextual) {
|
|
185
217
|
if (this._storedValue.asArray) {
|
|
186
218
|
serializationObject.valueType = "BABYLON." + this._storedValue.getClassName();
|
|
187
219
|
serializationObject.value = this._storedValue.asArray();
|
|
@@ -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;;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,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C/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC;QAEtC,IAAI,CAAC,eAAe,GAAG,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.FaceID:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Int;\r\n break;\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 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 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,K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AAG,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.FaceID:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Int;\r\n break;\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"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometryBuildState } from "../nodeGeometryBuildState";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to extract unique positions from a geometry
|
|
6
|
+
*/
|
|
7
|
+
export declare class GeometryOptimizeBlock extends NodeGeometryBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
10
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
11
|
+
*/
|
|
12
|
+
evaluateContext: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Define the epsilon used to compare similar positions
|
|
15
|
+
*/
|
|
16
|
+
epsilon: number;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new GeometryOptimizeBlock
|
|
19
|
+
* @param name defines the block name
|
|
20
|
+
*/
|
|
21
|
+
constructor(name: string);
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current class name
|
|
24
|
+
* @returns the class name
|
|
25
|
+
*/
|
|
26
|
+
getClassName(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the geometry component
|
|
29
|
+
*/
|
|
30
|
+
get geometry(): NodeGeometryConnectionPoint;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the output component
|
|
33
|
+
*/
|
|
34
|
+
get output(): NodeGeometryConnectionPoint;
|
|
35
|
+
protected _buildBlock(state: NodeGeometryBuildState): 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;
|
|
43
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { __decorate } from "../../../tslib.es6.js";
|
|
2
|
+
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
3
|
+
import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
|
+
import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
|
|
5
|
+
import { PropertyTypeForEdition, editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
|
|
6
|
+
import { VertexData } from "../../../Meshes/mesh.vertexData.js";
|
|
7
|
+
import { Scalar } from "../../../Maths/math.scalar.js";
|
|
8
|
+
import { Epsilon } from "../../../Maths/math.constants.js";
|
|
9
|
+
/**
|
|
10
|
+
* Block used to extract unique positions from a geometry
|
|
11
|
+
*/
|
|
12
|
+
export class GeometryOptimizeBlock extends NodeGeometryBlock {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new GeometryOptimizeBlock
|
|
15
|
+
* @param name defines the block name
|
|
16
|
+
*/
|
|
17
|
+
constructor(name) {
|
|
18
|
+
super(name);
|
|
19
|
+
/**
|
|
20
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
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
|
+
*/
|
|
23
|
+
this.evaluateContext = false;
|
|
24
|
+
/**
|
|
25
|
+
* Define the epsilon used to compare similar positions
|
|
26
|
+
*/
|
|
27
|
+
this.epsilon = Epsilon;
|
|
28
|
+
this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
29
|
+
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets the current class name
|
|
33
|
+
* @returns the class name
|
|
34
|
+
*/
|
|
35
|
+
getClassName() {
|
|
36
|
+
return "GeometryOptimizeBlock";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the geometry component
|
|
40
|
+
*/
|
|
41
|
+
get geometry() {
|
|
42
|
+
return this._inputs[0];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the output component
|
|
46
|
+
*/
|
|
47
|
+
get output() {
|
|
48
|
+
return this._outputs[0];
|
|
49
|
+
}
|
|
50
|
+
_buildBlock(state) {
|
|
51
|
+
const func = (state) => {
|
|
52
|
+
if (!this.geometry.isConnected) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const vertexData = this.geometry.getConnectedValue(state);
|
|
56
|
+
const newPositions = [];
|
|
57
|
+
const newIndicesMap = {};
|
|
58
|
+
for (let index = 0; index < vertexData.positions.length; index += 3) {
|
|
59
|
+
const x = vertexData.positions[index];
|
|
60
|
+
const y = vertexData.positions[index + 1];
|
|
61
|
+
const z = vertexData.positions[index + 2];
|
|
62
|
+
// check if we already have it
|
|
63
|
+
let found = false;
|
|
64
|
+
for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {
|
|
65
|
+
if (Scalar.WithinEpsilon(x, newPositions[checkIndex], this.epsilon) &&
|
|
66
|
+
Scalar.WithinEpsilon(y, newPositions[checkIndex + 1], this.epsilon) &&
|
|
67
|
+
Scalar.WithinEpsilon(z, newPositions[checkIndex + 2], this.epsilon)) {
|
|
68
|
+
newIndicesMap[index / 3] = checkIndex / 3;
|
|
69
|
+
found = true;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!found) {
|
|
74
|
+
newIndicesMap[index / 3] = newPositions.length / 3;
|
|
75
|
+
newPositions.push(x, y, z);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const newVertexData = new VertexData();
|
|
79
|
+
newVertexData.positions = newPositions;
|
|
80
|
+
newVertexData.indices = vertexData.indices.map((index) => newIndicesMap[index]);
|
|
81
|
+
return newVertexData;
|
|
82
|
+
};
|
|
83
|
+
if (this.evaluateContext) {
|
|
84
|
+
this.output._storedFunction = func;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.output._storedValue = func(state);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
_dumpPropertiesCode() {
|
|
91
|
+
let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
|
|
92
|
+
codeString += `${this._codeVariableName}.epsilon = ${this.epsilon};\n`;
|
|
93
|
+
return codeString;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Serializes this block in a JSON representation
|
|
97
|
+
* @returns the serialized block object
|
|
98
|
+
*/
|
|
99
|
+
serialize() {
|
|
100
|
+
const serializationObject = super.serialize();
|
|
101
|
+
serializationObject.evaluateContext = this.evaluateContext;
|
|
102
|
+
serializationObject.epsilon = this.epsilon;
|
|
103
|
+
return serializationObject;
|
|
104
|
+
}
|
|
105
|
+
_deserialize(serializationObject) {
|
|
106
|
+
super._deserialize(serializationObject);
|
|
107
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
108
|
+
this.epsilon = serializationObject.epsilon;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
__decorate([
|
|
112
|
+
editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
|
|
113
|
+
], GeometryOptimizeBlock.prototype, "evaluateContext", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
editableInPropertyPage("Epsilon", PropertyTypeForEdition.Float, "ADVANCED", { notifiers: { rebuild: true } })
|
|
116
|
+
], GeometryOptimizeBlock.prototype, "epsilon", void 0);
|
|
117
|
+
RegisterClass("BABYLON.GeometryOptimizeBlock", GeometryOptimizeBlock);
|
|
118
|
+
//# sourceMappingURL=geometryOptimizeBlock.js.map
|
|
@@ -0,0 +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,YAA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,CAAC,CAAC;SAC1C;IACL,CAAC;IAES,mBAAmB;QACzB,IAAI,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,sBAAsB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC3I,UAAU,IAAI,GAAG,IAAI,CAAC,iBAAiB,cAAc,IAAI,CAAC,OAAO,KAAK,CAAC;QACvE,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC3D,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE3C,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,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;AAjHU;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;AA6G7B,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._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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryOutputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOutputBlock.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;AAKlG;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAGtD;;OAEG;IACH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAdR,gBAAW,GAAyB,IAAI,CAAC;QAgB7C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,qBAAqB,CAAC;IACjC,CAAC;IACD;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC;IACxC,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,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 { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Nullable } from \"../../../types\";\r\n\r\n/**\r\n * Block used to generate the final geometry\r\n */\r\nexport class GeometryOutputBlock extends NodeGeometryBlock {\r\n private _vertexData: Nullable<VertexData> = null;\r\n\r\n /**\r\n * Gets the current vertex data if the graph was successfully built\r\n */\r\n public get currentVertexData() {\r\n return this._vertexData;\r\n }\r\n\r\n /**\r\n * Create a new GeometryOutputBlock\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 }\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 \"GeometryOutputBlock\";\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 protected _buildBlock(state: NodeGeometryBuildState) {\r\n state.vertexData = this.geometry.getConnectedValue(state);\r\n this._vertexData = state.vertexData;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOutputBlock\", GeometryOutputBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryOutputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOutputBlock.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;AAKlG;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAGtD;;OAEG;IACH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAdR,gBAAW,GAAyB,IAAI,CAAC;QAgB7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,qBAAqB,CAAC;IACjC,CAAC;IACD;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC;IACxC,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,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 { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Nullable } from \"../../../types\";\r\n\r\n/**\r\n * Block used to generate the final geometry\r\n */\r\nexport class GeometryOutputBlock extends NodeGeometryBlock {\r\n private _vertexData: Nullable<VertexData> = null;\r\n\r\n /**\r\n * Gets the current vertex data if the graph was successfully built\r\n */\r\n public get currentVertexData() {\r\n return this._vertexData;\r\n }\r\n\r\n /**\r\n * Create a new GeometryOutputBlock\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._isUnique = true;\r\n\r\n this.registerInput(\"geometry\", 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 \"GeometryOutputBlock\";\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 protected _buildBlock(state: NodeGeometryBuildState) {\r\n state.vertexData = this.geometry.getConnectedValue(state);\r\n this._vertexData = state.vertexData;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOutputBlock\", GeometryOutputBlock);\r\n"]}
|
|
@@ -2,7 +2,7 @@ import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
|
2
2
|
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
3
|
import type { NodeGeometryBuildState } from "../nodeGeometryBuildState";
|
|
4
4
|
/**
|
|
5
|
-
* Block used to apply a transform to vector
|
|
5
|
+
* Block used to apply a transform to a vector / geometry
|
|
6
6
|
*/
|
|
7
7
|
export declare class GeometryTransformBlock extends NodeGeometryBlock {
|
|
8
8
|
private _rotationMatrix;
|
|
@@ -50,4 +50,11 @@ export declare class GeometryTransformBlock extends NodeGeometryBlock {
|
|
|
50
50
|
*/
|
|
51
51
|
get output(): NodeGeometryConnectionPoint;
|
|
52
52
|
protected _buildBlock(state: NodeGeometryBuildState): void;
|
|
53
|
+
protected _dumpPropertiesCode(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Serializes this block in a JSON representation
|
|
56
|
+
* @returns the serialized block object
|
|
57
|
+
*/
|
|
58
|
+
serialize(): any;
|
|
59
|
+
_deserialize(serializationObject: any): void;
|
|
53
60
|
}
|
|
@@ -5,7 +5,7 @@ import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConn
|
|
|
5
5
|
import { Matrix, Vector2, Vector3, Vector4 } from "../../../Maths/math.vector.js";
|
|
6
6
|
import { PropertyTypeForEdition, editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
|
|
7
7
|
/**
|
|
8
|
-
* Block used to apply a transform to vector
|
|
8
|
+
* Block used to apply a transform to a vector / geometry
|
|
9
9
|
*/
|
|
10
10
|
export class GeometryTransformBlock extends NodeGeometryBlock {
|
|
11
11
|
/**
|
|
@@ -126,6 +126,25 @@ export class GeometryTransformBlock extends NodeGeometryBlock {
|
|
|
126
126
|
this.output._storedValue = func(state);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
_dumpPropertiesCode() {
|
|
130
|
+
const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
|
|
131
|
+
return codeString;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Serializes this block in a JSON representation
|
|
135
|
+
* @returns the serialized block object
|
|
136
|
+
*/
|
|
137
|
+
serialize() {
|
|
138
|
+
const serializationObject = super.serialize();
|
|
139
|
+
serializationObject.evaluateContext = this.evaluateContext;
|
|
140
|
+
return serializationObject;
|
|
141
|
+
}
|
|
142
|
+
_deserialize(serializationObject) {
|
|
143
|
+
super._deserialize(serializationObject);
|
|
144
|
+
if (serializationObject.evaluateContext !== undefined) {
|
|
145
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
129
148
|
}
|
|
130
149
|
__decorate([
|
|
131
150
|
editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryTransformBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryTransformBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAA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AAG,IAAI,CAAC,gBAAgB,CAAC;aAClC;YAED,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBACrB,KAAK,qCAAqC,CAAC,QAAQ,CAAC,CAAC;oBACjD,MAAM,QAAQ,GAAI,KAAoB,CAAC,KAAK,EAAE,CAAC;oBAC/C,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;oBAC3B,OAAO,QAAQ,CAAC;iBACnB;gBACD,KAAK,qCAAqC,CAAC,OAAO;oBAC9C,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC5C,KAAK,qCAAqC,CAAC,OAAO;oBAC9C,OAAO,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACvD,KAAK,qCAAqC,CAAC,OAAO;oBAC9C,OAAO,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;aAC1D;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;CACJ;AAhIU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;+DAC3F;AAkIlC,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,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 { Matrix, Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to apply a transform to vector\r\n */\r\nexport class GeometryTransformBlock extends NodeGeometryBlock {\r\n private _rotationMatrix = new Matrix();\r\n private _scalingMatrix = new Matrix();\r\n private _translationMatrix = new Matrix();\r\n private _scalingRotationMatrix = new Matrix();\r\n private _transformMatrix = new Matrix();\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 GeometryTransformBlock\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(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"translation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(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 \"GeometryTransformBlock\";\r\n }\r\n\r\n /**\r\n * Gets the value input component\r\n */\r\n public get value(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the translation input component\r\n */\r\n public get translation(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n if (!this.value.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const value = this.value.getConnectedValue(state);\r\n\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n let matrix: Matrix;\r\n\r\n if (this.matrix.isConnected) {\r\n matrix = this.matrix.getConnectedValue(state);\r\n } else {\r\n const scaling = this.scaling.getConnectedValue(state);\r\n const rotation = this.rotation.getConnectedValue(state);\r\n const translation = this.translation.getConnectedValue(state);\r\n\r\n // Transform\r\n Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, this._scalingMatrix);\r\n Matrix.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, this._rotationMatrix);\r\n Matrix.TranslationToRef(translation.x, translation.y, translation.z, this._translationMatrix);\r\n\r\n this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix);\r\n this._scalingRotationMatrix.multiplyToRef(this._translationMatrix, this._transformMatrix);\r\n matrix = this._transformMatrix;\r\n }\r\n\r\n switch (this.value.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Geometry: {\r\n const geometry = (value as VertexData).clone();\r\n geometry.transform(matrix);\r\n return geometry;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return Vector2.Transform(value, matrix);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return Vector3.TransformCoordinates(value, matrix);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return Vector4.TransformCoordinates(value, matrix);\r\n }\r\n\r\n return null;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTransformBlock\", GeometryTransformBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryTransformBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryTransformBlock.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,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGnG;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IAczD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAlBR,oBAAe,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,mBAAc,GAAG,IAAI,MAAM,EAAE,CAAC;QAC9B,uBAAkB,GAAG,IAAI,MAAM,EAAE,CAAC;QAClC,2BAAsB,GAAG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,MAAM,CAAC,CAAC;aAC1D;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;IAES,mBAAmB;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,sBAAsB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC7I,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAzJU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;+DAC3F;AA2JlC,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,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 { Matrix, Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to apply a transform to a vector / geometry\r\n */\r\nexport class GeometryTransformBlock extends NodeGeometryBlock {\r\n private _rotationMatrix = new Matrix();\r\n private _scalingMatrix = new Matrix();\r\n private _translationMatrix = new Matrix();\r\n private _scalingRotationMatrix = new Matrix();\r\n private _transformMatrix = new Matrix();\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 GeometryTransformBlock\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(\"value\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"translation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[0].excludedConnectionPointTypes.push(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 \"GeometryTransformBlock\";\r\n }\r\n\r\n /**\r\n * Gets the value input component\r\n */\r\n public get value(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the translation input component\r\n */\r\n public get translation(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n if (!this.value.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const value = this.value.getConnectedValue(state);\r\n\r\n if (!value) {\r\n return null;\r\n }\r\n\r\n let matrix: Matrix;\r\n\r\n if (this.matrix.isConnected) {\r\n matrix = this.matrix.getConnectedValue(state);\r\n } else {\r\n const scaling = this.scaling.getConnectedValue(state);\r\n const rotation = this.rotation.getConnectedValue(state);\r\n const translation = this.translation.getConnectedValue(state);\r\n\r\n // Transform\r\n Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, this._scalingMatrix);\r\n Matrix.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, this._rotationMatrix);\r\n Matrix.TranslationToRef(translation.x, translation.y, translation.z, this._translationMatrix);\r\n\r\n this._scalingMatrix.multiplyToRef(this._rotationMatrix, this._scalingRotationMatrix);\r\n this._scalingRotationMatrix.multiplyToRef(this._translationMatrix, this._transformMatrix);\r\n matrix = this._transformMatrix;\r\n }\r\n\r\n switch (this.value.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Geometry: {\r\n const geometry = (value as VertexData).clone();\r\n geometry.transform(matrix);\r\n return geometry;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2:\r\n return Vector2.Transform(value, matrix);\r\n case NodeGeometryBlockConnectionPointTypes.Vector3:\r\n return Vector3.TransformCoordinates(value, matrix);\r\n case NodeGeometryBlockConnectionPointTypes.Vector4:\r\n return Vector4.TransformCoordinates(value, matrix);\r\n }\r\n\r\n return null;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"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.evaluateContext = this.evaluateContext;\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 if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTransformBlock\", GeometryTransformBlock);\r\n"]}
|
|
@@ -65,6 +65,8 @@ export class GeometryTrigonometryBlock extends NodeGeometryBlock {
|
|
|
65
65
|
this.registerInput("input", NodeGeometryBlockConnectionPointTypes.AutoDetect);
|
|
66
66
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.BasedOnInput);
|
|
67
67
|
this._outputs[0]._typeConnectionSource = this._inputs[0];
|
|
68
|
+
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);
|
|
69
|
+
this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Gets the current class name
|
|
@@ -172,6 +174,7 @@ export class GeometryTrigonometryBlock extends NodeGeometryBlock {
|
|
|
172
174
|
return;
|
|
173
175
|
}
|
|
174
176
|
switch (this.input.type) {
|
|
177
|
+
case NodeGeometryBlockConnectionPointTypes.Int:
|
|
175
178
|
case NodeGeometryBlockConnectionPointTypes.Float: {
|
|
176
179
|
this.output._storedFunction = (state) => {
|
|
177
180
|
const source = this.input.getConnectedValue(state);
|
|
@@ -214,7 +217,7 @@ export class GeometryTrigonometryBlock extends NodeGeometryBlock {
|
|
|
214
217
|
}
|
|
215
218
|
_dumpPropertiesCode() {
|
|
216
219
|
const codeString = super._dumpPropertiesCode() +
|
|
217
|
-
`${this._codeVariableName}.operation = BABYLON.GeometryTrigonometryBlockOperations.${GeometryTrigonometryBlockOperations[this.operation]};\
|
|
220
|
+
`${this._codeVariableName}.operation = BABYLON.GeometryTrigonometryBlockOperations.${GeometryTrigonometryBlockOperations[this.operation]};\n`;
|
|
218
221
|
return codeString;
|
|
219
222
|
}
|
|
220
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryTrigonometryBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryTrigonometryBlock.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,C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M,EAAE,KAAK,EAAE,mCAAmC,CAAC,IAAI,EAAE;YAClE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC,CAAC,GAAG,EAAE;YAChE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC,CAAC,GAAG,EAAE;YAChE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mCAAmC,CAAC,MAAM,EAAE;YACtE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mCAAmC,CAAC,MAAM,EAAE;YACtE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mCAAmC,CAAC,MAAM,EAAE;YACtE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mCAAmC,CAAC,IAAI,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mCAAmC,CAAC,MAAM,EAAE;YACtE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mCAAmC,CAAC,QAAQ,EAAE;YAC1E,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,mCAAmC,CAAC,UAAU,EAAE;YAC9E,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mCAAmC,CAAC,SAAS,EAAE;YAC5E,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mCAAmC,CAAC,SAAS,EAAE;SAC/E;KACJ,CAAC;4DACyD;AAqL/D,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,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 { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Operations supported by the Trigonometry block\r\n */\r\nexport enum GeometryTrigonometryBlockOperations {\r\n /** Cos */\r\n Cos,\r\n /** Sin */\r\n Sin,\r\n /** Abs */\r\n Abs,\r\n /** Exp */\r\n Exp,\r\n /** Round */\r\n Round,\r\n /** Floor */\r\n Floor,\r\n /** Ceiling */\r\n Ceiling,\r\n /** Square root */\r\n Sqrt,\r\n /** Log */\r\n Log,\r\n /** Tangent */\r\n Tan,\r\n /** Arc tangent */\r\n ArcTan,\r\n /** Arc cosinus */\r\n ArcCos,\r\n /** Arc sinus */\r\n ArcSin,\r\n /** Sign */\r\n Sign,\r\n /** Negate */\r\n Negate,\r\n /** OneMinus */\r\n OneMinus,\r\n /** Reciprocal */\r\n Reciprocal,\r\n /** ToDegrees */\r\n ToDegrees,\r\n /** ToRadians */\r\n ToRadians,\r\n}\r\n\r\n/**\r\n * Block used to apply trigonometry operation to floats\r\n */\r\nexport class GeometryTrigonometryBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Cos\", value: GeometryTrigonometryBlockOperations.Cos },\r\n { label: \"Sin\", value: GeometryTrigonometryBlockOperations.Sin },\r\n { label: \"Abs\", value: GeometryTrigonometryBlockOperations.Abs },\r\n { label: \"Exp\", value: GeometryTrigonometryBlockOperations.Exp },\r\n { label: \"Round\", value: GeometryTrigonometryBlockOperations.Round },\r\n { label: \"Floor\", value: GeometryTrigonometryBlockOperations.Floor },\r\n { label: \"Ceiling\", value: GeometryTrigonometryBlockOperations.Ceiling },\r\n { label: \"Sqrt\", value: GeometryTrigonometryBlockOperations.Sqrt },\r\n { label: \"Log\", value: GeometryTrigonometryBlockOperations.Log },\r\n { label: \"Tan\", value: GeometryTrigonometryBlockOperations.Tan },\r\n { label: \"ArcTan\", value: GeometryTrigonometryBlockOperations.ArcTan },\r\n { label: \"ArcCos\", value: GeometryTrigonometryBlockOperations.ArcCos },\r\n { label: \"ArcSin\", value: GeometryTrigonometryBlockOperations.ArcSin },\r\n { label: \"Sign\", value: GeometryTrigonometryBlockOperations.Sign },\r\n { label: \"Negate\", value: GeometryTrigonometryBlockOperations.Negate },\r\n { label: \"OneMinus\", value: GeometryTrigonometryBlockOperations.OneMinus },\r\n { label: \"Reciprocal\", value: GeometryTrigonometryBlockOperations.Reciprocal },\r\n { label: \"ToDegrees\", value: GeometryTrigonometryBlockOperations.ToDegrees },\r\n { label: \"ToRadians\", value: GeometryTrigonometryBlockOperations.ToRadians },\r\n ],\r\n })\r\n public operation = GeometryTrigonometryBlockOperations.Cos;\r\n\r\n /**\r\n * Creates a new GeometryTrigonometryBlock\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 }\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 \"GeometryTrigonometryBlock\";\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(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n let func: Nullable<(value: number) => number> = null;\r\n\r\n switch (this.operation) {\r\n case GeometryTrigonometryBlockOperations.Cos: {\r\n func = (value: number) => Math.cos(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sin: {\r\n func = (value: number) => Math.sin(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Abs: {\r\n func = (value: number) => Math.abs(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Exp: {\r\n func = (value: number) => Math.exp(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Round: {\r\n func = (value: number) => Math.round(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Floor: {\r\n func = (value: number) => Math.floor(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Ceiling: {\r\n func = (value: number) => Math.ceil(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sqrt: {\r\n func = (value: number) => Math.sqrt(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Log: {\r\n func = (value: number) => Math.log(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Tan: {\r\n func = (value: number) => Math.tan(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcTan: {\r\n func = (value: number) => Math.atan(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcCos: {\r\n func = (value: number) => Math.acos(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcSin: {\r\n func = (value: number) => Math.asin(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sign: {\r\n func = (value: number) => Math.sign(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Negate: {\r\n func = (value: number) => -value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.OneMinus: {\r\n func = (value: number) => 1 - value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Reciprocal: {\r\n func = (value: number) => 1 / value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ToRadians: {\r\n func = (value: number) => (value * Math.PI) / 180;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ToDegrees: {\r\n func = (value: number) => (value * 180) / Math.PI;\r\n break;\r\n }\r\n }\r\n if (!func) {\r\n this.input._storedFunction = null;\r\n this.input._storedValue = null;\r\n return;\r\n }\r\n\r\n switch (this.input.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return func!(source);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector2(func!(source.x), func!(source.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector3(func!(source.x), func!(source.y), func!(source.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector4(func!(source.x), func!(source.y), func!(source.z), func!(source.w));\r\n };\r\n break;\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString =\r\n super._dumpPropertiesCode() +\r\n `${this._codeVariableName}.operation = BABYLON.GeometryTrigonometryBlockOperations.${GeometryTrigonometryBlockOperations[this.operation]};\\r\\n`;\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTrigonometryBlock\", GeometryTrigonometryBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryTrigonometryBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryTrigonometryBlock.ts"],"names":[],"m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,EAAE,KAAK,EAAE,mCAAmC,CAAC,UAAU,EAAE;YAC9E,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mCAAmC,CAAC,SAAS,EAAE;YAC5E,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mCAAmC,CAAC,SAAS,EAAE;SAC/E;KACJ,CAAC;4DACyD;AAwL/D,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,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 { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Operations supported by the Trigonometry block\r\n */\r\nexport enum GeometryTrigonometryBlockOperations {\r\n /** Cos */\r\n Cos,\r\n /** Sin */\r\n Sin,\r\n /** Abs */\r\n Abs,\r\n /** Exp */\r\n Exp,\r\n /** Round */\r\n Round,\r\n /** Floor */\r\n Floor,\r\n /** Ceiling */\r\n Ceiling,\r\n /** Square root */\r\n Sqrt,\r\n /** Log */\r\n Log,\r\n /** Tangent */\r\n Tan,\r\n /** Arc tangent */\r\n ArcTan,\r\n /** Arc cosinus */\r\n ArcCos,\r\n /** Arc sinus */\r\n ArcSin,\r\n /** Sign */\r\n Sign,\r\n /** Negate */\r\n Negate,\r\n /** OneMinus */\r\n OneMinus,\r\n /** Reciprocal */\r\n Reciprocal,\r\n /** ToDegrees */\r\n ToDegrees,\r\n /** ToRadians */\r\n ToRadians,\r\n}\r\n\r\n/**\r\n * Block used to apply trigonometry operation to floats\r\n */\r\nexport class GeometryTrigonometryBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the operation applied by the block\r\n */\r\n @editableInPropertyPage(\"Operation\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n options: [\r\n { label: \"Cos\", value: GeometryTrigonometryBlockOperations.Cos },\r\n { label: \"Sin\", value: GeometryTrigonometryBlockOperations.Sin },\r\n { label: \"Abs\", value: GeometryTrigonometryBlockOperations.Abs },\r\n { label: \"Exp\", value: GeometryTrigonometryBlockOperations.Exp },\r\n { label: \"Round\", value: GeometryTrigonometryBlockOperations.Round },\r\n { label: \"Floor\", value: GeometryTrigonometryBlockOperations.Floor },\r\n { label: \"Ceiling\", value: GeometryTrigonometryBlockOperations.Ceiling },\r\n { label: \"Sqrt\", value: GeometryTrigonometryBlockOperations.Sqrt },\r\n { label: \"Log\", value: GeometryTrigonometryBlockOperations.Log },\r\n { label: \"Tan\", value: GeometryTrigonometryBlockOperations.Tan },\r\n { label: \"ArcTan\", value: GeometryTrigonometryBlockOperations.ArcTan },\r\n { label: \"ArcCos\", value: GeometryTrigonometryBlockOperations.ArcCos },\r\n { label: \"ArcSin\", value: GeometryTrigonometryBlockOperations.ArcSin },\r\n { label: \"Sign\", value: GeometryTrigonometryBlockOperations.Sign },\r\n { label: \"Negate\", value: GeometryTrigonometryBlockOperations.Negate },\r\n { label: \"OneMinus\", value: GeometryTrigonometryBlockOperations.OneMinus },\r\n { label: \"Reciprocal\", value: GeometryTrigonometryBlockOperations.Reciprocal },\r\n { label: \"ToDegrees\", value: GeometryTrigonometryBlockOperations.ToDegrees },\r\n { label: \"ToRadians\", value: GeometryTrigonometryBlockOperations.ToRadians },\r\n ],\r\n })\r\n public operation = GeometryTrigonometryBlockOperations.Cos;\r\n\r\n /**\r\n * Creates a new GeometryTrigonometryBlock\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.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(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 \"GeometryTrigonometryBlock\";\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(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n let func: Nullable<(value: number) => number> = null;\r\n\r\n switch (this.operation) {\r\n case GeometryTrigonometryBlockOperations.Cos: {\r\n func = (value: number) => Math.cos(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sin: {\r\n func = (value: number) => Math.sin(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Abs: {\r\n func = (value: number) => Math.abs(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Exp: {\r\n func = (value: number) => Math.exp(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Round: {\r\n func = (value: number) => Math.round(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Floor: {\r\n func = (value: number) => Math.floor(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Ceiling: {\r\n func = (value: number) => Math.ceil(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sqrt: {\r\n func = (value: number) => Math.sqrt(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Log: {\r\n func = (value: number) => Math.log(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Tan: {\r\n func = (value: number) => Math.tan(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcTan: {\r\n func = (value: number) => Math.atan(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcCos: {\r\n func = (value: number) => Math.acos(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ArcSin: {\r\n func = (value: number) => Math.asin(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Sign: {\r\n func = (value: number) => Math.sign(value);\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Negate: {\r\n func = (value: number) => -value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.OneMinus: {\r\n func = (value: number) => 1 - value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.Reciprocal: {\r\n func = (value: number) => 1 / value;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ToRadians: {\r\n func = (value: number) => (value * Math.PI) / 180;\r\n break;\r\n }\r\n case GeometryTrigonometryBlockOperations.ToDegrees: {\r\n func = (value: number) => (value * 180) / Math.PI;\r\n break;\r\n }\r\n }\r\n if (!func) {\r\n this.input._storedFunction = null;\r\n this.input._storedValue = null;\r\n return;\r\n }\r\n\r\n switch (this.input.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return func!(source);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector2(func!(source.x), func!(source.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector3(func!(source.x), func!(source.y), func!(source.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n this.output._storedFunction = (state) => {\r\n const source = this.input.getConnectedValue(state);\r\n return new Vector4(func!(source.x), func!(source.y), func!(source.z), func!(source.w));\r\n };\r\n break;\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.operation = this.operation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.operation = serializationObject.operation;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString =\r\n super._dumpPropertiesCode() +\r\n `${this._codeVariableName}.operation = BABYLON.GeometryTrigonometryBlockOperations.${GeometryTrigonometryBlockOperations[this.operation]};\\n`;\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTrigonometryBlock\", GeometryTrigonometryBlock);\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"intFloatConverterBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/intFloatConverterBlock.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,sBAAuB,SAAQ,iBAAiB;IACzD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAE5E,IAAI,CAAC,c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,CAAC,OAAO,CAAC,WAAW,EAAE;gBAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACpD;YACD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;gBACxB,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAClD;YAED,OAAO,CAAC,CAAC;QACb,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,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 convert from int to float\r\n */\r\nexport class IntFloatConverterBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new IntFloatConverterBlock\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(\"float \", NodeGeometryBlockConnectionPointTypes.Float, true);\r\n this.registerInput(\"int \", NodeGeometryBlockConnectionPointTypes.Int, true);\r\n\r\n this.registerOutput(\"float\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"int\", NodeGeometryBlockConnectionPointTypes.Int);\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 \"IntFloatConverterBlock\";\r\n }\r\n\r\n /**\r\n * Gets the float input component\r\n */\r\n public get floatIn(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the int input component\r\n */\r\n public get intIn(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the float output component\r\n */\r\n public get floatOut(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the int output component\r\n */\r\n public get intOut(): NodeGeometryConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n protected _inputRename(name: string) {\r\n if (name === \"float \") {\r\n return \"floatIn\";\r\n }\r\n if (name === \"int \") {\r\n return \"intIn\";\r\n }\r\n return name;\r\n }\r\n\r\n protected _buildBlock() {\r\n this.floatOut._storedFunction = (state) => {\r\n if (this.floatIn.isConnected) {\r\n return this.floatIn.getConnectedValue(state);\r\n }\r\n if (this.intIn.isConnected) {\r\n return this.intIn.getConnectedValue(state);\r\n }\r\n\r\n return 0;\r\n };\r\n\r\n this.intOut._storedFunction = (state) => {\r\n if (this.floatIn.isConnected) {\r\n return this.floatIn.getConnectedValue(state) | 0;\r\n }\r\n if (this.intIn.isConnected) {\r\n return this.intIn.getConnectedValue(state) | 0;\r\n }\r\n\r\n return 0;\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.IntFloatConverterBlock\", IntFloatConverterBlock);\r\n"]}
|