@babylonjs/core 6.19.0 → 6.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/actionManager.js +2 -2
- package/Actions/actionManager.js.map +1 -1
- package/Animations/runtimeAnimation.js +2 -2
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.d.ts +4 -4
- package/Cameras/Inputs/BaseCameraPointersInput.js +4 -6
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +3 -2
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +3 -2
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -7
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -7
- package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +4 -14
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -1
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +2 -7
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +2 -0
- package/Cameras/camera.js +8 -0
- package/Cameras/camera.js.map +1 -1
- package/Compute/computeShader.d.ts +15 -0
- package/Compute/computeShader.js +39 -0
- package/Compute/computeShader.js.map +1 -1
- package/Debug/physicsViewer.d.ts +33 -0
- package/Debug/physicsViewer.js +205 -0
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/Extensions/engine.computeShader.d.ts +2 -1
- package/Engines/Extensions/engine.computeShader.js +1 -0
- package/Engines/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/webgpuComputeContext.js +15 -0
- package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.d.ts +23 -0
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.js +18 -0
- package/FlowGraph/Blocks/Data/flowGraphAddBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +30 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +22 -0
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +33 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +30 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +3 -1
- package/FlowGraph/Blocks/Data/index.js +3 -1
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +12 -10
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +25 -29
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +25 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +31 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +3 -7
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +11 -11
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.d.ts +24 -0
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js +23 -0
- package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +10 -13
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +28 -22
- package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +5 -5
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +8 -6
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.d.ts +56 -0
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js +66 -0
- package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +18 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +19 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +26 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +36 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +23 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +25 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.d.ts +16 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js +18 -0
- package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.d.ts +32 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js +62 -0
- package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/index.d.ts +7 -0
- package/FlowGraph/Blocks/Execution/index.js +7 -0
- package/FlowGraph/Blocks/Execution/index.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +42 -12
- package/FlowGraph/flowGraph.js +37 -23
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +29 -0
- package/FlowGraph/flowGraphAsyncExecutionBlock.js +21 -0
- package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -0
- package/FlowGraph/flowGraphBlock.d.ts +9 -11
- package/FlowGraph/flowGraphBlock.js +12 -8
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +17 -7
- package/FlowGraph/flowGraphConnection.js +26 -9
- package/FlowGraph/flowGraphConnection.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +102 -0
- package/FlowGraph/flowGraphContext.js +111 -0
- package/FlowGraph/flowGraphContext.js.map +1 -0
- package/FlowGraph/flowGraphCustomEvent.d.ts +5 -0
- package/FlowGraph/flowGraphCustomEvent.js +2 -0
- package/FlowGraph/flowGraphCustomEvent.js.map +1 -0
- package/FlowGraph/flowGraphDataConnection.d.ts +10 -2
- package/FlowGraph/flowGraphDataConnection.js +16 -8
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.d.ts +5 -12
- package/FlowGraph/flowGraphEventBlock.js +5 -5
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphEventCoordinator.d.ts +23 -0
- package/FlowGraph/flowGraphEventCoordinator.js +37 -0
- package/FlowGraph/flowGraphEventCoordinator.js.map +1 -0
- package/FlowGraph/flowGraphExecutionBlock.d.ts +5 -5
- package/FlowGraph/flowGraphExecutionBlock.js +3 -3
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphRichTypes.d.ts +28 -0
- package/FlowGraph/flowGraphRichTypes.js +43 -0
- package/FlowGraph/flowGraphRichTypes.js.map +1 -0
- package/FlowGraph/flowGraphSignalConnection.d.ts +7 -1
- package/FlowGraph/flowGraphSignalConnection.js +11 -4
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/flowGraphVariableDefinitions.d.ts +12 -0
- package/FlowGraph/flowGraphVariableDefinitions.js +22 -0
- package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -0
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +10 -2
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -2
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
- package/FlowGraph/index.d.ts +3 -0
- package/FlowGraph/index.js +3 -0
- package/FlowGraph/index.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -1
- package/Materials/Node/nodeMaterial.js +26 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +5 -0
- package/Materials/Textures/videoTexture.js +6 -0
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/materialHelper.js +1 -0
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -0
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +7 -0
- package/Materials/uniformBuffer.js +8 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -0
- package/Maths/math.vector.js +7 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBlock.d.ts +11 -5
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js +20 -10
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +15 -9
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +20 -11
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +7 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +19 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +54 -19
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +12 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js +62 -27
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +5 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +65 -46
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/debugBlock.js +5 -1
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/intFloatConverterBlock.js +2 -2
- package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js +8 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +1 -0
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/matrixComposeBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/matrixComposeBlock.js +55 -0
- package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +3 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +2 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.d.ts +10 -0
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js +2 -0
- package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js.map +1 -0
- package/Meshes/Node/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +2 -2
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.d.ts +5 -0
- package/Meshes/Node/nodeGeometryBuildState.js +20 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +10 -10
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.js +7 -5
- package/Meshes/mesh.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +2 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/dumpTools.js +3 -2
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/equirectangularCapture.d.ts +39 -0
- package/Misc/equirectangularCapture.js +56 -0
- package/Misc/equirectangularCapture.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +4 -0
- package/Particles/solidParticleSystem.js +16 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +8 -1
- package/Physics/v2/Plugins/havokPlugin.js +34 -0
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +11 -1
- package/Physics/v2/physicsConstraint.js +7 -0
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Rendering/prePassRenderer.d.ts +6 -0
- package/Rendering/prePassRenderer.js +14 -0
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/default.fragment.js +4 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/equirectangularPanorama.fragment.d.ts +5 -0
- package/Shaders/equirectangularPanorama.fragment.js +17 -0
- package/Shaders/equirectangularPanorama.fragment.js.map +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +0 -34
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +0 -29
- package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +0 -1
|
@@ -2,10 +2,11 @@ import { NodeGeometryBlock } from "../../nodeGeometryBlock";
|
|
|
2
2
|
import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnectionPoint";
|
|
3
3
|
import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
|
|
4
4
|
import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
|
|
5
|
+
import type { INodeGeometryInstancingContext } from "../../Interfaces/nodeGeometryInstancingContext";
|
|
5
6
|
/**
|
|
6
7
|
* Block used to instantiate a geometry inside a loop
|
|
7
8
|
*/
|
|
8
|
-
export declare class InstantiateBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
|
|
9
|
+
export declare class InstantiateBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {
|
|
9
10
|
private _vertexData;
|
|
10
11
|
private _currentIndex;
|
|
11
12
|
/**
|
|
@@ -18,6 +19,11 @@ export declare class InstantiateBlock extends NodeGeometryBlock implements INode
|
|
|
18
19
|
* @param name defines the block name
|
|
19
20
|
*/
|
|
20
21
|
constructor(name: string);
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current instance index in the current flow
|
|
24
|
+
* @returns the current index
|
|
25
|
+
*/
|
|
26
|
+
getInstanceIndex(): number;
|
|
21
27
|
/**
|
|
22
28
|
* Gets the current index in the current flow
|
|
23
29
|
* @returns the current index
|
|
@@ -46,6 +52,10 @@ export declare class InstantiateBlock extends NodeGeometryBlock implements INode
|
|
|
46
52
|
* Gets the instance input component
|
|
47
53
|
*/
|
|
48
54
|
get count(): NodeGeometryConnectionPoint;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the matrix input component
|
|
57
|
+
*/
|
|
58
|
+
get matrix(): NodeGeometryConnectionPoint;
|
|
49
59
|
/**
|
|
50
60
|
* Gets the position input component
|
|
51
61
|
*/
|
|
@@ -58,10 +68,6 @@ export declare class InstantiateBlock extends NodeGeometryBlock implements INode
|
|
|
58
68
|
* Gets the scaling input component
|
|
59
69
|
*/
|
|
60
70
|
get scaling(): NodeGeometryConnectionPoint;
|
|
61
|
-
/**
|
|
62
|
-
* Gets the matrix input component
|
|
63
|
-
*/
|
|
64
|
-
get matrix(): NodeGeometryConnectionPoint;
|
|
65
71
|
/**
|
|
66
72
|
* Gets the geometry output component
|
|
67
73
|
*/
|
|
@@ -21,13 +21,20 @@ export class InstantiateBlock extends NodeGeometryBlock {
|
|
|
21
21
|
this.evaluateContext = true;
|
|
22
22
|
this.registerInput("instance", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
23
23
|
this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 1);
|
|
24
|
+
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
24
25
|
this.registerInput("position", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
25
26
|
this.registerInput("rotation", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
26
27
|
this.registerInput("scaling", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());
|
|
27
|
-
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
28
28
|
this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
|
|
29
29
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets the current instance index in the current flow
|
|
33
|
+
* @returns the current index
|
|
34
|
+
*/
|
|
35
|
+
getInstanceIndex() {
|
|
36
|
+
return this._currentIndex;
|
|
37
|
+
}
|
|
31
38
|
/**
|
|
32
39
|
* Gets the current index in the current flow
|
|
33
40
|
* @returns the current index
|
|
@@ -69,27 +76,27 @@ export class InstantiateBlock extends NodeGeometryBlock {
|
|
|
69
76
|
return this._inputs[1];
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
72
|
-
* Gets the
|
|
79
|
+
* Gets the matrix input component
|
|
73
80
|
*/
|
|
74
|
-
get
|
|
81
|
+
get matrix() {
|
|
75
82
|
return this._inputs[2];
|
|
76
83
|
}
|
|
77
84
|
/**
|
|
78
|
-
* Gets the
|
|
85
|
+
* Gets the position input component
|
|
79
86
|
*/
|
|
80
|
-
get
|
|
87
|
+
get position() {
|
|
81
88
|
return this._inputs[3];
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
* Gets the
|
|
91
|
+
* Gets the rotation input component
|
|
85
92
|
*/
|
|
86
|
-
get
|
|
93
|
+
get rotation() {
|
|
87
94
|
return this._inputs[4];
|
|
88
95
|
}
|
|
89
96
|
/**
|
|
90
|
-
* Gets the
|
|
97
|
+
* Gets the scaling input component
|
|
91
98
|
*/
|
|
92
|
-
get
|
|
99
|
+
get scaling() {
|
|
93
100
|
return this._inputs[5];
|
|
94
101
|
}
|
|
95
102
|
/**
|
|
@@ -101,6 +108,7 @@ export class InstantiateBlock extends NodeGeometryBlock {
|
|
|
101
108
|
_buildBlock(state) {
|
|
102
109
|
const func = (state) => {
|
|
103
110
|
state.executionContext = this;
|
|
111
|
+
state.instancingContext = this;
|
|
104
112
|
// Processing
|
|
105
113
|
const iterationCount = this.count.getConnectedValue(state);
|
|
106
114
|
const additionalVertexData = [];
|
|
@@ -159,7 +167,9 @@ export class InstantiateBlock extends NodeGeometryBlock {
|
|
|
159
167
|
}
|
|
160
168
|
_deserialize(serializationObject) {
|
|
161
169
|
super._deserialize(serializationObject);
|
|
162
|
-
|
|
170
|
+
if (serializationObject.evaluateContext !== undefined) {
|
|
171
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
172
|
+
}
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instantiateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE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AAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to instantiate a geometry inside a loop\r\n */\r\nexport class InstantiateBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\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 InstantiateBlock\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(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 1);\r\n this.registerInput(\"position\", 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 this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateBlock\";\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the position input component\r\n */\r\n public get position(): 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 matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n\r\n // Processing\r\n const iterationCount = this.count.getConnectedValue(state);\r\n const additionalVertexData: VertexData[] = [];\r\n\r\n for (this._currentIndex = 0; this._currentIndex < iterationCount; this._currentIndex++) {\r\n const instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n\r\n // Clone the instance\r\n const clone = instanceGeometry.clone();\r\n\r\n // Transform\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithMatrix(clone, transform, additionalVertexData);\r\n } else {\r\n const position = this.position.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, position, rotation, scaling, additionalVertexData);\r\n }\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\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 this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.InstantiateBlock\", InstantiateBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"instantiateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,gDAAsC;AAG/F;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAWnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrF,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACpG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACpG,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,C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AC/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;AA1LU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;yDAC3F;AA4LlC,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport type { INodeGeometryInstancingContext } from \"../../Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Block used to instantiate a geometry inside a loop\r\n */\r\nexport class InstantiateBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\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 InstantiateBlock\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(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 1);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"position\", 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.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current instance index in the current flow\r\n * @returns the current index\r\n */\r\n public getInstanceIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateBlock\";\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\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[2];\r\n }\r\n\r\n /**\r\n * Gets the position input component\r\n */\r\n public get position(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\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[4];\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[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n state.instancingContext = this;\r\n\r\n // Processing\r\n const iterationCount = this.count.getConnectedValue(state);\r\n const additionalVertexData: VertexData[] = [];\r\n\r\n for (this._currentIndex = 0; this._currentIndex < iterationCount; this._currentIndex++) {\r\n const instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n\r\n // Clone the instance\r\n const clone = instanceGeometry.clone();\r\n\r\n // Transform\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithMatrix(clone, transform, additionalVertexData);\r\n } else {\r\n const position = this.position.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, position, rotation, scaling, additionalVertexData);\r\n }\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\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.InstantiateBlock\", InstantiateBlock);\r\n"]}
|
|
@@ -3,10 +3,11 @@ import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnect
|
|
|
3
3
|
import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
|
|
4
4
|
import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
|
|
5
5
|
import { Vector3 } from "../../../../Maths/math.vector";
|
|
6
|
+
import type { INodeGeometryInstancingContext } from "../../Interfaces/nodeGeometryInstancingContext";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to instance geometry on every face of a geometry
|
|
8
9
|
*/
|
|
9
|
-
export declare class InstantiateOnFacesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
|
|
10
|
+
export declare class InstantiateOnFacesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {
|
|
10
11
|
private _vertexData;
|
|
11
12
|
private _currentFaceIndex;
|
|
12
13
|
private _currentLoopIndex;
|
|
@@ -26,6 +27,11 @@ export declare class InstantiateOnFacesBlock extends NodeGeometryBlock implement
|
|
|
26
27
|
* @param name defines the block name
|
|
27
28
|
*/
|
|
28
29
|
constructor(name: string);
|
|
30
|
+
/**
|
|
31
|
+
* Gets the current instance index in the current flow
|
|
32
|
+
* @returns the current index
|
|
33
|
+
*/
|
|
34
|
+
getInstanceIndex(): number;
|
|
29
35
|
/**
|
|
30
36
|
* Gets the current index in the current flow
|
|
31
37
|
* @returns the current index
|
|
@@ -65,21 +71,21 @@ export declare class InstantiateOnFacesBlock extends NodeGeometryBlock implement
|
|
|
65
71
|
*/
|
|
66
72
|
get instance(): NodeGeometryConnectionPoint;
|
|
67
73
|
/**
|
|
68
|
-
* Gets the
|
|
69
|
-
*/
|
|
70
|
-
get rotation(): NodeGeometryConnectionPoint;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the scaling input component
|
|
74
|
+
* Gets the count input component
|
|
73
75
|
*/
|
|
74
|
-
get
|
|
76
|
+
get count(): NodeGeometryConnectionPoint;
|
|
75
77
|
/**
|
|
76
78
|
* Gets the matrix input component
|
|
77
79
|
*/
|
|
78
80
|
get matrix(): NodeGeometryConnectionPoint;
|
|
79
81
|
/**
|
|
80
|
-
* Gets the
|
|
82
|
+
* Gets the rotation input component
|
|
81
83
|
*/
|
|
82
|
-
get
|
|
84
|
+
get rotation(): NodeGeometryConnectionPoint;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the scaling input component
|
|
87
|
+
*/
|
|
88
|
+
get scaling(): NodeGeometryConnectionPoint;
|
|
83
89
|
/**
|
|
84
90
|
* Gets the geometry output component
|
|
85
91
|
*/
|
|
@@ -27,13 +27,20 @@ export class InstantiateOnFacesBlock extends NodeGeometryBlock {
|
|
|
27
27
|
this.evaluateContext = true;
|
|
28
28
|
this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
29
29
|
this.registerInput("instance", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
30
|
+
this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 256);
|
|
31
|
+
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
30
32
|
this.registerInput("rotation", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
31
33
|
this.registerInput("scaling", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());
|
|
32
|
-
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
33
|
-
this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 256);
|
|
34
34
|
this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
|
|
35
35
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the current instance index in the current flow
|
|
39
|
+
* @returns the current index
|
|
40
|
+
*/
|
|
41
|
+
getInstanceIndex() {
|
|
42
|
+
return this._currentLoopIndex;
|
|
43
|
+
}
|
|
37
44
|
/**
|
|
38
45
|
* Gets the current index in the current flow
|
|
39
46
|
* @returns the current index
|
|
@@ -93,27 +100,27 @@ export class InstantiateOnFacesBlock extends NodeGeometryBlock {
|
|
|
93
100
|
return this._inputs[1];
|
|
94
101
|
}
|
|
95
102
|
/**
|
|
96
|
-
* Gets the
|
|
103
|
+
* Gets the count input component
|
|
97
104
|
*/
|
|
98
|
-
get
|
|
105
|
+
get count() {
|
|
99
106
|
return this._inputs[2];
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
102
|
-
* Gets the
|
|
109
|
+
* Gets the matrix input component
|
|
103
110
|
*/
|
|
104
|
-
get
|
|
111
|
+
get matrix() {
|
|
105
112
|
return this._inputs[3];
|
|
106
113
|
}
|
|
107
114
|
/**
|
|
108
|
-
* Gets the
|
|
115
|
+
* Gets the rotation input component
|
|
109
116
|
*/
|
|
110
|
-
get
|
|
117
|
+
get rotation() {
|
|
111
118
|
return this._inputs[4];
|
|
112
119
|
}
|
|
113
120
|
/**
|
|
114
|
-
* Gets the
|
|
121
|
+
* Gets the scaling input component
|
|
115
122
|
*/
|
|
116
|
-
get
|
|
123
|
+
get scaling() {
|
|
117
124
|
return this._inputs[5];
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
@@ -125,11 +132,13 @@ export class InstantiateOnFacesBlock extends NodeGeometryBlock {
|
|
|
125
132
|
_buildBlock(state) {
|
|
126
133
|
const func = (state) => {
|
|
127
134
|
state.executionContext = this;
|
|
135
|
+
state.instancingContext = this;
|
|
128
136
|
this._vertexData = this.geometry.getConnectedValue(state);
|
|
129
137
|
state.geometryContext = this._vertexData;
|
|
130
138
|
if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {
|
|
131
139
|
state.executionContext = null;
|
|
132
140
|
state.geometryContext = null;
|
|
141
|
+
state.instancingContext = null;
|
|
133
142
|
this.output._storedValue = null;
|
|
134
143
|
return;
|
|
135
144
|
}
|
|
@@ -176,7 +185,7 @@ export class InstantiateOnFacesBlock extends NodeGeometryBlock {
|
|
|
176
185
|
const clone = instanceGeometry.clone();
|
|
177
186
|
if (this.matrix.isConnected) {
|
|
178
187
|
const transform = this.matrix.getConnectedValue(state);
|
|
179
|
-
state.
|
|
188
|
+
state._instantiateWithPositionAndMatrix(clone, this._currentPosition, transform, additionalVertexData);
|
|
180
189
|
}
|
|
181
190
|
else {
|
|
182
191
|
const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instantiateOnFacesBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa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AAC,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;AAzPU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;gEAC3F;AA2PlC,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Nullable } from \"../../../../types\";\r\n\r\n/**\r\n * Block used to instance geometry on every face of a geometry\r\n */\r\nexport class InstantiateOnFacesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentFaceIndex: number;\r\n private _currentLoopIndex: number;\r\n private _currentPosition = new Vector3();\r\n private _vertex0 = new Vector3();\r\n private _vertex1 = new Vector3();\r\n private _vertex2 = new Vector3();\r\n private _tempVector0 = new Vector3();\r\n private _tempVector1 = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new InstantiateOnFacesBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 256);\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return this._currentFaceIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * @returns the value associated with the source\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._currentPosition;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * @returns the value associated with the source\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n this._vertex1.subtractToRef(this._vertex0, this._tempVector0);\r\n this._vertex2.subtractToRef(this._vertex1, this._tempVector1);\r\n this._tempVector0.normalize();\r\n this._tempVector1.normalize();\r\n return Vector3.Cross(this._tempVector1, this._tempVector0);\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 \"InstantiateOnFacesBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\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[2];\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[3];\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[4];\r\n }\r\n\r\n /**\r\n * Gets the count input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let instanceGeometry: Nullable<VertexData> = null;\r\n const instanceCount = this.count.getConnectedValue(state);\r\n const faceCount = this._vertexData.indices.length / 3;\r\n const instancePerFace = instanceCount / faceCount;\r\n let accumulatedCount = 0;\r\n const additionalVertexData: VertexData[] = [];\r\n let totalDone = 0;\r\n this._currentLoopIndex = 0;\r\n\r\n for (this._currentFaceIndex = 0; this._currentFaceIndex < faceCount; this._currentFaceIndex++) {\r\n // Extract face vertices\r\n this._vertex0.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3] * 3);\r\n this._vertex1.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3 + 1] * 3);\r\n this._vertex2.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3 + 2] * 3);\r\n\r\n accumulatedCount += instancePerFace;\r\n const countPerFace = (accumulatedCount | 0) - totalDone;\r\n\r\n if (countPerFace < 1) {\r\n continue;\r\n }\r\n\r\n for (let faceDispatchCount = 0; faceDispatchCount < countPerFace; faceDispatchCount++) {\r\n if (totalDone >= instanceCount) {\r\n break;\r\n }\r\n\r\n // Get random point on face\r\n let x = Math.random();\r\n let y = Math.random();\r\n\r\n if (x > y) {\r\n const temp = x;\r\n x = y;\r\n y = temp;\r\n }\r\n const s = x;\r\n const t = y - x;\r\n const u = 1 - s - t;\r\n\r\n this._currentPosition.set(\r\n s * this._vertex0.x + t * this._vertex1.x + u * this._vertex2.x,\r\n s * this._vertex0.y + t * this._vertex1.y + u * this._vertex2.y,\r\n s * this._vertex0.z + t * this._vertex1.z + u * this._vertex2.z\r\n );\r\n\r\n // Clone the instance\r\n instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n const clone = instanceGeometry!.clone();\r\n\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithMatrix(clone, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, this._currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n totalDone++;\r\n this._currentLoopIndex++;\r\n }\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\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.InstantiateOnFacesBlock\", InstantiateOnFacesBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"instantiateOnFacesBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAItG;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IAkB1D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAnBR,qBAAgB,GAAG,IAAI,OAAO,EAAE,CAAC;QACjC,aAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,aAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,aAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,iBAAY,GAAG,IAAI,OAAO,EAAE,CAAC;QAC7B,iBAAY,GAAG,IAAI,OAAO,EAAE,CAAC;QAErC;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrF,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAClF,IA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sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;gEAC3F;AAoQlC,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport type { INodeGeometryInstancingContext } from \"../../Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Block used to instance geometry on every face of a geometry\r\n */\r\nexport class InstantiateOnFacesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {\r\n private _vertexData: VertexData;\r\n private _currentFaceIndex: number;\r\n private _currentLoopIndex: number;\r\n private _currentPosition = new Vector3();\r\n private _vertex0 = new Vector3();\r\n private _vertex1 = new Vector3();\r\n private _vertex2 = new Vector3();\r\n private _tempVector0 = new Vector3();\r\n private _tempVector1 = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new InstantiateOnFacesBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 256);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\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.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current instance index in the current flow\r\n * @returns the current index\r\n */\r\n public getInstanceIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return this._currentFaceIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * @returns the value associated with the source\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._currentPosition;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * @returns the value associated with the source\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n this._vertex1.subtractToRef(this._vertex0, this._tempVector0);\r\n this._vertex2.subtractToRef(this._vertex1, this._tempVector1);\r\n this._tempVector0.normalize();\r\n this._tempVector1.normalize();\r\n return Vector3.Cross(this._tempVector1, this._tempVector0);\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 \"InstantiateOnFacesBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the count input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\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[3];\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[4];\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[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n state.instancingContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n state.instancingContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let instanceGeometry: Nullable<VertexData> = null;\r\n const instanceCount = this.count.getConnectedValue(state);\r\n const faceCount = this._vertexData.indices.length / 3;\r\n const instancePerFace = instanceCount / faceCount;\r\n let accumulatedCount = 0;\r\n const additionalVertexData: VertexData[] = [];\r\n let totalDone = 0;\r\n this._currentLoopIndex = 0;\r\n\r\n for (this._currentFaceIndex = 0; this._currentFaceIndex < faceCount; this._currentFaceIndex++) {\r\n // Extract face vertices\r\n this._vertex0.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3] * 3);\r\n this._vertex1.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3 + 1] * 3);\r\n this._vertex2.fromArray(this._vertexData.positions, this._vertexData.indices[this._currentFaceIndex * 3 + 2] * 3);\r\n\r\n accumulatedCount += instancePerFace;\r\n const countPerFace = (accumulatedCount | 0) - totalDone;\r\n\r\n if (countPerFace < 1) {\r\n continue;\r\n }\r\n\r\n for (let faceDispatchCount = 0; faceDispatchCount < countPerFace; faceDispatchCount++) {\r\n if (totalDone >= instanceCount) {\r\n break;\r\n }\r\n\r\n // Get random point on face\r\n let x = Math.random();\r\n let y = Math.random();\r\n\r\n if (x > y) {\r\n const temp = x;\r\n x = y;\r\n y = temp;\r\n }\r\n const s = x;\r\n const t = y - x;\r\n const u = 1 - s - t;\r\n\r\n this._currentPosition.set(\r\n s * this._vertex0.x + t * this._vertex1.x + u * this._vertex2.x,\r\n s * this._vertex0.y + t * this._vertex1.y + u * this._vertex2.y,\r\n s * this._vertex0.z + t * this._vertex1.z + u * this._vertex2.z\r\n );\r\n\r\n // Clone the instance\r\n instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n const clone = instanceGeometry!.clone();\r\n\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithPositionAndMatrix(clone, this._currentPosition, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, this._currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n totalDone++;\r\n this._currentLoopIndex++;\r\n }\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\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.InstantiateOnFacesBlock\", InstantiateOnFacesBlock);\r\n"]}
|
|
@@ -2,10 +2,11 @@ import { NodeGeometryBlock } from "../../nodeGeometryBlock";
|
|
|
2
2
|
import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnectionPoint";
|
|
3
3
|
import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
|
|
4
4
|
import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
|
|
5
|
+
import type { INodeGeometryInstancingContext } from "../../Interfaces/nodeGeometryInstancingContext";
|
|
5
6
|
/**
|
|
6
7
|
* Block used to instance geometry on every vertex of a geometry
|
|
7
8
|
*/
|
|
8
|
-
export declare class InstantiateOnVerticesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
|
|
9
|
+
export declare class InstantiateOnVerticesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {
|
|
9
10
|
private _vertexData;
|
|
10
11
|
private _currentIndex;
|
|
11
12
|
private _currentLoopIndex;
|
|
@@ -24,6 +25,11 @@ export declare class InstantiateOnVerticesBlock extends NodeGeometryBlock implem
|
|
|
24
25
|
* @param name defines the block name
|
|
25
26
|
*/
|
|
26
27
|
constructor(name: string);
|
|
28
|
+
/**
|
|
29
|
+
* Gets the current instance index in the current flow
|
|
30
|
+
* @returns the current index
|
|
31
|
+
*/
|
|
32
|
+
getInstanceIndex(): number;
|
|
27
33
|
/**
|
|
28
34
|
* Gets the current index in the current flow
|
|
29
35
|
* @returns the current index
|
|
@@ -53,21 +59,21 @@ export declare class InstantiateOnVerticesBlock extends NodeGeometryBlock implem
|
|
|
53
59
|
*/
|
|
54
60
|
get instance(): NodeGeometryConnectionPoint;
|
|
55
61
|
/**
|
|
56
|
-
* Gets the
|
|
57
|
-
*/
|
|
58
|
-
get rotation(): NodeGeometryConnectionPoint;
|
|
59
|
-
/**
|
|
60
|
-
* Gets the scaling input component
|
|
62
|
+
* Gets the density input component
|
|
61
63
|
*/
|
|
62
|
-
get
|
|
64
|
+
get density(): NodeGeometryConnectionPoint;
|
|
63
65
|
/**
|
|
64
66
|
* Gets the matrix input component
|
|
65
67
|
*/
|
|
66
68
|
get matrix(): NodeGeometryConnectionPoint;
|
|
67
69
|
/**
|
|
68
|
-
* Gets the
|
|
70
|
+
* Gets the rotation input component
|
|
69
71
|
*/
|
|
70
|
-
get
|
|
72
|
+
get rotation(): NodeGeometryConnectionPoint;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the scaling input component
|
|
75
|
+
*/
|
|
76
|
+
get scaling(): NodeGeometryConnectionPoint;
|
|
71
77
|
/**
|
|
72
78
|
* Gets the geometry output component
|
|
73
79
|
*/
|
|
@@ -27,13 +27,20 @@ export class InstantiateOnVerticesBlock extends NodeGeometryBlock {
|
|
|
27
27
|
this.removeDuplicatedPositions = true;
|
|
28
28
|
this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
29
29
|
this.registerInput("instance", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
30
|
+
this.registerInput("density", NodeGeometryBlockConnectionPointTypes.Float, true, 1, 0, 1);
|
|
31
|
+
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
30
32
|
this.registerInput("rotation", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
31
33
|
this.registerInput("scaling", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());
|
|
32
|
-
this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
|
|
33
|
-
this.registerInput("density", NodeGeometryBlockConnectionPointTypes.Float, true, 1, 0, 1);
|
|
34
34
|
this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
|
|
35
35
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the current instance index in the current flow
|
|
39
|
+
* @returns the current index
|
|
40
|
+
*/
|
|
41
|
+
getInstanceIndex() {
|
|
42
|
+
return this._currentLoopIndex;
|
|
43
|
+
}
|
|
37
44
|
/**
|
|
38
45
|
* Gets the current index in the current flow
|
|
39
46
|
* @returns the current index
|
|
@@ -75,27 +82,27 @@ export class InstantiateOnVerticesBlock extends NodeGeometryBlock {
|
|
|
75
82
|
return this._inputs[1];
|
|
76
83
|
}
|
|
77
84
|
/**
|
|
78
|
-
* Gets the
|
|
85
|
+
* Gets the density input component
|
|
79
86
|
*/
|
|
80
|
-
get
|
|
87
|
+
get density() {
|
|
81
88
|
return this._inputs[2];
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
* Gets the
|
|
91
|
+
* Gets the matrix input component
|
|
85
92
|
*/
|
|
86
|
-
get
|
|
93
|
+
get matrix() {
|
|
87
94
|
return this._inputs[3];
|
|
88
95
|
}
|
|
89
96
|
/**
|
|
90
|
-
* Gets the
|
|
97
|
+
* Gets the rotation input component
|
|
91
98
|
*/
|
|
92
|
-
get
|
|
99
|
+
get rotation() {
|
|
93
100
|
return this._inputs[4];
|
|
94
101
|
}
|
|
95
102
|
/**
|
|
96
|
-
* Gets the
|
|
103
|
+
* Gets the scaling input component
|
|
97
104
|
*/
|
|
98
|
-
get
|
|
105
|
+
get scaling() {
|
|
99
106
|
return this._inputs[5];
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
@@ -107,11 +114,13 @@ export class InstantiateOnVerticesBlock extends NodeGeometryBlock {
|
|
|
107
114
|
_buildBlock(state) {
|
|
108
115
|
const func = (state) => {
|
|
109
116
|
state.executionContext = this;
|
|
117
|
+
state.instancingContext = this;
|
|
110
118
|
this._vertexData = this.geometry.getConnectedValue(state);
|
|
111
119
|
state.geometryContext = this._vertexData;
|
|
112
120
|
if (!this._vertexData || !this._vertexData.positions || !this.instance.isConnected) {
|
|
113
121
|
state.executionContext = null;
|
|
114
122
|
state.geometryContext = null;
|
|
123
|
+
state.instancingContext = null;
|
|
115
124
|
this.output._storedValue = null;
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
@@ -164,7 +173,7 @@ export class InstantiateOnVerticesBlock extends NodeGeometryBlock {
|
|
|
164
173
|
// Transform
|
|
165
174
|
if (this.matrix.isConnected) {
|
|
166
175
|
const transform = this.matrix.getConnectedValue(state);
|
|
167
|
-
state.
|
|
176
|
+
state._instantiateWithPositionAndMatrix(clone, currentPosition, transform, additionalVertexData);
|
|
168
177
|
}
|
|
169
178
|
else {
|
|
170
179
|
const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);
|