@babylonjs/core 6.16.2 → 6.17.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/Animations/animatable.d.ts +4 -0
- package/Animations/animatable.js +7 -1
- package/Animations/animatable.js.map +1 -1
- package/Animations/animationGroup.d.ts +16 -0
- package/Animations/animationGroup.js +50 -0
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/animationGroupMask.d.ts +63 -0
- package/Animations/animationGroupMask.js +83 -0
- package/Animations/animationGroupMask.js.map +1 -0
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +77 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +198 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.d.ts +10 -2
- package/Meshes/Node/Blocks/noiseBlock.js +22 -4
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- 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/index.d.ts +1 -0
- package/Meshes/Node/index.js +1 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +2 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +9 -0
- package/Meshes/mesh.vertexData.js +10 -0
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Particles/IGPUParticleSystemPlatform.d.ts +2 -2
- package/Particles/IGPUParticleSystemPlatform.js.map +1 -1
- package/Particles/computeShaderParticleSystem.d.ts +2 -2
- package/Particles/computeShaderParticleSystem.js +2 -2
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +2 -0
- package/Particles/gpuParticleSystem.js +16 -3
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +2 -0
- package/Particles/particleSystem.js +40 -7
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.d.ts +4 -2
- package/Particles/webgl2ParticleSystem.js +8 -2
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +18 -1
- package/Physics/v2/physicsBody.js +26 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
|
|
4
|
+
import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
|
|
5
|
+
import { Vector3 } from "../../../../Maths/math.vector";
|
|
6
|
+
/**
|
|
7
|
+
* Block used to instance geometry inside a geometry
|
|
8
|
+
*/
|
|
9
|
+
export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
|
|
10
|
+
private _vertexData;
|
|
11
|
+
private _currentPosition;
|
|
12
|
+
private _vertex0;
|
|
13
|
+
private _vertex1;
|
|
14
|
+
private _vertex2;
|
|
15
|
+
/**
|
|
16
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
17
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
18
|
+
*/
|
|
19
|
+
evaluateContext: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new InstantiateOnVolumeBlock
|
|
22
|
+
* @param name defines the block name
|
|
23
|
+
*/
|
|
24
|
+
constructor(name: string);
|
|
25
|
+
/**
|
|
26
|
+
* Gets the current index in the current flow
|
|
27
|
+
* @returns the current index
|
|
28
|
+
*/
|
|
29
|
+
getExecutionIndex(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the current face index in the current flow
|
|
32
|
+
* @returns the current face index
|
|
33
|
+
*/
|
|
34
|
+
getExecutionFaceIndex(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the value associated with a contextual positions
|
|
37
|
+
* @returns the value associated with the source
|
|
38
|
+
*/
|
|
39
|
+
getOverridePositionsContextualValue(): Vector3;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the current class name
|
|
42
|
+
* @returns the class name
|
|
43
|
+
*/
|
|
44
|
+
getClassName(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the geometry input component
|
|
47
|
+
*/
|
|
48
|
+
get geometry(): NodeGeometryConnectionPoint;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the instance input component
|
|
51
|
+
*/
|
|
52
|
+
get instance(): NodeGeometryConnectionPoint;
|
|
53
|
+
/**
|
|
54
|
+
* Gets the rotation input component
|
|
55
|
+
*/
|
|
56
|
+
get rotation(): NodeGeometryConnectionPoint;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the scaling input component
|
|
59
|
+
*/
|
|
60
|
+
get scaling(): NodeGeometryConnectionPoint;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the count input component
|
|
63
|
+
*/
|
|
64
|
+
get count(): NodeGeometryConnectionPoint;
|
|
65
|
+
/**
|
|
66
|
+
* Gets the geometry output component
|
|
67
|
+
*/
|
|
68
|
+
get output(): NodeGeometryConnectionPoint;
|
|
69
|
+
protected _buildBlock(state: NodeGeometryBuildState): void;
|
|
70
|
+
protected _dumpPropertiesCode(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Serializes this block in a JSON representation
|
|
73
|
+
* @returns the serialized block object
|
|
74
|
+
*/
|
|
75
|
+
serialize(): any;
|
|
76
|
+
_deserialize(serializationObject: any): void;
|
|
77
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { __decorate } from "../../../../tslib.es6.js";
|
|
2
|
+
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
3
|
+
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
4
|
+
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
5
|
+
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
6
|
+
import { PropertyTypeForEdition, editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
7
|
+
import { Ray } from "../../../../Culling/ray.js";
|
|
8
|
+
import { extractMinAndMax } from "../../../../Maths/math.functions.js";
|
|
9
|
+
/**
|
|
10
|
+
* Block used to instance geometry inside a geometry
|
|
11
|
+
*/
|
|
12
|
+
export class InstantiateOnVolumeBlock extends NodeGeometryBlock {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new InstantiateOnVolumeBlock
|
|
15
|
+
* @param name defines the block name
|
|
16
|
+
*/
|
|
17
|
+
constructor(name) {
|
|
18
|
+
super(name);
|
|
19
|
+
this._currentPosition = new Vector3();
|
|
20
|
+
this._vertex0 = new Vector3();
|
|
21
|
+
this._vertex1 = new Vector3();
|
|
22
|
+
this._vertex2 = new Vector3();
|
|
23
|
+
/**
|
|
24
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
25
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
26
|
+
*/
|
|
27
|
+
this.evaluateContext = true;
|
|
28
|
+
this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
29
|
+
this.registerInput("instance", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
30
|
+
this.registerInput("rotation", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
31
|
+
this.registerInput("scaling", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());
|
|
32
|
+
this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 256);
|
|
33
|
+
this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
|
|
34
|
+
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the current index in the current flow
|
|
38
|
+
* @returns the current index
|
|
39
|
+
*/
|
|
40
|
+
getExecutionIndex() {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the current face index in the current flow
|
|
45
|
+
* @returns the current face index
|
|
46
|
+
*/
|
|
47
|
+
getExecutionFaceIndex() {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the value associated with a contextual positions
|
|
52
|
+
* @returns the value associated with the source
|
|
53
|
+
*/
|
|
54
|
+
getOverridePositionsContextualValue() {
|
|
55
|
+
return this._currentPosition;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the current class name
|
|
59
|
+
* @returns the class name
|
|
60
|
+
*/
|
|
61
|
+
getClassName() {
|
|
62
|
+
return "InstantiateOnVolumeBlock";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the geometry input component
|
|
66
|
+
*/
|
|
67
|
+
get geometry() {
|
|
68
|
+
return this._inputs[0];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the instance input component
|
|
72
|
+
*/
|
|
73
|
+
get instance() {
|
|
74
|
+
return this._inputs[1];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the rotation input component
|
|
78
|
+
*/
|
|
79
|
+
get rotation() {
|
|
80
|
+
return this._inputs[2];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the scaling input component
|
|
84
|
+
*/
|
|
85
|
+
get scaling() {
|
|
86
|
+
return this._inputs[3];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets the count input component
|
|
90
|
+
*/
|
|
91
|
+
get count() {
|
|
92
|
+
return this._inputs[4];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the geometry output component
|
|
96
|
+
*/
|
|
97
|
+
get output() {
|
|
98
|
+
return this._outputs[0];
|
|
99
|
+
}
|
|
100
|
+
_buildBlock(state) {
|
|
101
|
+
state.executionContext = this;
|
|
102
|
+
this._vertexData = this.geometry.getConnectedValue(state);
|
|
103
|
+
state.geometryContext = this._vertexData;
|
|
104
|
+
if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {
|
|
105
|
+
state.executionContext = null;
|
|
106
|
+
state.geometryContext = null;
|
|
107
|
+
this.output._storedValue = null;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Processing
|
|
111
|
+
let instanceGeometry = null;
|
|
112
|
+
if (!this.evaluateContext) {
|
|
113
|
+
instanceGeometry = this.instance.getConnectedValue(state);
|
|
114
|
+
if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {
|
|
115
|
+
state.executionContext = null;
|
|
116
|
+
state.geometryContext = null;
|
|
117
|
+
this.output._storedValue = null;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const instanceCount = this.count.getConnectedValue(state);
|
|
122
|
+
const additionalVertexData = [];
|
|
123
|
+
const boundingInfo = extractMinAndMax(this._vertexData.positions, 0, this._vertexData.positions.length / 3);
|
|
124
|
+
const min = boundingInfo.minimum;
|
|
125
|
+
const max = boundingInfo.maximum;
|
|
126
|
+
const direction = new Vector3(1, 0, 0);
|
|
127
|
+
const faceCount = this._vertexData.indices.length / 3;
|
|
128
|
+
for (let index = 0; index < instanceCount; index++) {
|
|
129
|
+
this._currentPosition.set(Math.random() * (max.x - min.x) + min.x, Math.random() * (max.y - min.y) + min.y, Math.random() * (max.z - min.z) + min.z);
|
|
130
|
+
// Cast a ray from the random point in an arbitrary direction
|
|
131
|
+
const ray = new Ray(this._currentPosition, direction);
|
|
132
|
+
let intersectionCount = 0;
|
|
133
|
+
for (let currentFaceIndex = 0; currentFaceIndex < faceCount; currentFaceIndex++) {
|
|
134
|
+
// Extract face vertices
|
|
135
|
+
this._vertex0.fromArray(this._vertexData.positions, this._vertexData.indices[currentFaceIndex * 3] * 3);
|
|
136
|
+
this._vertex1.fromArray(this._vertexData.positions, this._vertexData.indices[currentFaceIndex * 3 + 1] * 3);
|
|
137
|
+
this._vertex2.fromArray(this._vertexData.positions, this._vertexData.indices[currentFaceIndex * 3 + 2] * 3);
|
|
138
|
+
const currentIntersectInfo = ray.intersectsTriangle(this._vertex0, this._vertex1, this._vertex2);
|
|
139
|
+
if (currentIntersectInfo && currentIntersectInfo.distance > 0) {
|
|
140
|
+
intersectionCount++;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (intersectionCount % 2 === 0) {
|
|
144
|
+
// We are outside, try again
|
|
145
|
+
index--;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
// Clone the instance
|
|
149
|
+
if (this.evaluateContext) {
|
|
150
|
+
instanceGeometry = this.instance.getConnectedValue(state);
|
|
151
|
+
if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const clone = instanceGeometry.clone();
|
|
156
|
+
const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);
|
|
157
|
+
const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;
|
|
158
|
+
state._instantiate(clone, this._currentPosition, rotation, scaling, additionalVertexData);
|
|
159
|
+
}
|
|
160
|
+
// Merge
|
|
161
|
+
if (additionalVertexData.length) {
|
|
162
|
+
if (additionalVertexData.length === 1) {
|
|
163
|
+
this._vertexData = additionalVertexData[0];
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// We do not merge the main one as user can use a merge node if wanted
|
|
167
|
+
const main = additionalVertexData.splice(0, 1)[0];
|
|
168
|
+
this._vertexData = main.merge(additionalVertexData, true, false, true, true);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Storage
|
|
172
|
+
this.output._storedValue = this._vertexData;
|
|
173
|
+
state.executionContext = null;
|
|
174
|
+
state.geometryContext = null;
|
|
175
|
+
}
|
|
176
|
+
_dumpPropertiesCode() {
|
|
177
|
+
const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
|
|
178
|
+
return codeString;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Serializes this block in a JSON representation
|
|
182
|
+
* @returns the serialized block object
|
|
183
|
+
*/
|
|
184
|
+
serialize() {
|
|
185
|
+
const serializationObject = super.serialize();
|
|
186
|
+
serializationObject.evaluateContext = this.evaluateContext;
|
|
187
|
+
return serializationObject;
|
|
188
|
+
}
|
|
189
|
+
_deserialize(serializationObject) {
|
|
190
|
+
super._deserialize(serializationObject);
|
|
191
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
__decorate([
|
|
195
|
+
editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
|
|
196
|
+
], InstantiateOnVolumeBlock.prototype, "evaluateContext", void 0);
|
|
197
|
+
RegisterClass("BABYLON.InstantiateOnVolumeBlock", InstantiateOnVolumeBlock);
|
|
198
|
+
//# sourceMappingURL=instantiateOnVolumeBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantiateOnVolumeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.ts"],"names":[],"mappings":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CAAC;iEAC3F;AAiNlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,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 { Ray } from \"../../../../Culling/ray\";\r\nimport { extractMinAndMax } from \"../../../../Maths/math.functions\";\r\n\r\n/**\r\n * Block used to instance geometry inside a geometry\r\n */\r\nexport class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\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\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 InstantiateOnVolumeBlock\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(\"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 0;\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 current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateOnVolumeBlock\";\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 count input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\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 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 if (!this.evaluateContext) {\r\n instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\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\r\n const instanceCount = this.count.getConnectedValue(state);\r\n const additionalVertexData: VertexData[] = [];\r\n const boundingInfo = extractMinAndMax(this._vertexData.positions!, 0, this._vertexData.positions!.length / 3);\r\n const min = boundingInfo.minimum;\r\n const max = boundingInfo.maximum;\r\n const direction = new Vector3(1, 0, 0);\r\n const faceCount = this._vertexData.indices.length / 3;\r\n\r\n for (let index = 0; index < instanceCount; index++) {\r\n this._currentPosition.set(Math.random() * (max.x - min.x) + min.x, Math.random() * (max.y - min.y) + min.y, Math.random() * (max.z - min.z) + min.z);\r\n\r\n // Cast a ray from the random point in an arbitrary direction\r\n const ray = new Ray(this._currentPosition, direction);\r\n\r\n let intersectionCount = 0;\r\n for (let currentFaceIndex = 0; currentFaceIndex < faceCount; currentFaceIndex++) {\r\n // Extract face vertices\r\n this._vertex0.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3] * 3);\r\n this._vertex1.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 1] * 3);\r\n this._vertex2.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 2] * 3);\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(this._vertex0, this._vertex1, this._vertex2);\r\n\r\n if (currentIntersectInfo && currentIntersectInfo.distance > 0) {\r\n intersectionCount++;\r\n }\r\n }\r\n\r\n if (intersectionCount % 2 === 0) {\r\n // We are outside, try again\r\n index--;\r\n continue;\r\n }\r\n\r\n // Clone the instance\r\n if (this.evaluateContext) {\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 }\r\n const clone = instanceGeometry!.clone();\r\n\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\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 // Storage\r\n this.output._storedValue = this._vertexData;\r\n state.executionContext = null;\r\n state.geometryContext = null;\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.InstantiateOnVolumeBlock\", InstantiateOnVolumeBlock);\r\n"]}
|
|
@@ -68,6 +68,7 @@ export class GeometryInputBlock extends NodeGeometryBlock {
|
|
|
68
68
|
this._type = NodeGeometryBlockConnectionPointTypes.Vector2;
|
|
69
69
|
break;
|
|
70
70
|
case NodeGeometryContextualSources.VertexID:
|
|
71
|
+
case NodeGeometryContextualSources.GeometryID:
|
|
71
72
|
case NodeGeometryContextualSources.FaceID:
|
|
72
73
|
this._type = NodeGeometryBlockConnectionPointTypes.Int;
|
|
73
74
|
break;
|
|
@@ -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,OAAO,CAAC;wBAC3D,O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\"../../../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"]}
|
|
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,I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CAAC,SAAS,KAAK,QAAQ,EAAE;YAC5C,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC;SACjD;aAAM;YACH,MAAM,SAAS,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACtE;SACJ;IACL,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { Observable } from \"../../../Misc/observable\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { GetClass, RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Matrix, Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to expose an input value\r\n */\r\nexport class GeometryInputBlock extends NodeGeometryBlock {\r\n private _storedValue: any;\r\n private _valueCallback: () => any;\r\n private _type: NodeGeometryBlockConnectionPointTypes = NodeGeometryBlockConnectionPointTypes.Undefined;\r\n private _contextualSource = NodeGeometryContextualSources.None;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public min: number = 0;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public max: number = 0;\r\n\r\n /** Gets or sets the group to use to display this block in the Inspector */\r\n public groupInInspector = \"\";\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<GeometryInputBlock>();\r\n\r\n /**\r\n * Gets or sets the connection point type (default is float)\r\n */\r\n public get type(): NodeGeometryBlockConnectionPointTypes {\r\n if (this._type === NodeGeometryBlockConnectionPointTypes.AutoDetect) {\r\n if (this.value != null) {\r\n if (!isNaN(this.value)) {\r\n this._type = NodeGeometryBlockConnectionPointTypes.Float;\r\n return this._type;\r\n }\r\n\r\n switch (this.value.getClassName()) {\r\n case \"Vector2\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n return this._type;\r\n case \"Vector3\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n return this._type;\r\n case \"Vector4\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n return this._type;\r\n case \"Matrix\":\r\n this._type = NodeGeometryBlockConnectionPointTypes.Matrix;\r\n return this._type;\r\n }\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the current connection point is a contextual value\r\n */\r\n public get isContextual(): boolean {\r\n return this._contextualSource !== NodeGeometryContextualSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the current contextual value\r\n */\r\n public get contextualValue(): NodeGeometryContextualSources {\r\n return this._contextualSource;\r\n }\r\n\r\n public set contextualValue(value: NodeGeometryContextualSources) {\r\n this._contextualSource = value;\r\n\r\n switch (value) {\r\n case NodeGeometryContextualSources.Positions:\r\n case NodeGeometryContextualSources.Normals:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector3;\r\n break;\r\n case NodeGeometryContextualSources.Colors:\r\n case NodeGeometryContextualSources.Tangents:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector4;\r\n break;\r\n case NodeGeometryContextualSources.UV:\r\n case NodeGeometryContextualSources.UV2:\r\n case NodeGeometryContextualSources.UV3:\r\n case NodeGeometryContextualSources.UV4:\r\n case NodeGeometryContextualSources.UV5:\r\n case NodeGeometryContextualSources.UV6:\r\n this._type = NodeGeometryBlockConnectionPointTypes.Vector2;\r\n break;\r\n case NodeGeometryContextualSources.VertexID:\r\n case NodeGeometryContextualSources.GeometryID:\r\n case NodeGeometryContextualSources.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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
2
|
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
-
import
|
|
3
|
+
import { Vector3 } from "../../../Maths/math.vector";
|
|
4
4
|
/**
|
|
5
5
|
* Block used to get a noise value
|
|
6
6
|
*/
|
|
@@ -15,6 +15,14 @@ export declare class NoiseBlock extends NodeGeometryBlock {
|
|
|
15
15
|
* @returns the class name
|
|
16
16
|
*/
|
|
17
17
|
getClassName(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the offset input component
|
|
20
|
+
*/
|
|
21
|
+
get offset(): NodeGeometryConnectionPoint;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the scale input component
|
|
24
|
+
*/
|
|
25
|
+
get scale(): NodeGeometryConnectionPoint;
|
|
18
26
|
/**
|
|
19
27
|
* Gets the octaves input component
|
|
20
28
|
*/
|
|
@@ -44,6 +52,6 @@ export declare class NoiseBlock extends NodeGeometryBlock {
|
|
|
44
52
|
* @returns a value between 0 and 1
|
|
45
53
|
* @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533
|
|
46
54
|
*/
|
|
47
|
-
noise(octaves: number, roughness: number,
|
|
55
|
+
noise(octaves: number, roughness: number, _position: Vector3, offset: Vector3, scale: number): number;
|
|
48
56
|
protected _buildBlock(): void;
|
|
49
57
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../nodeGeometryBlock.js";
|
|
2
2
|
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
3
3
|
import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
4
5
|
import { Scalar } from "../../../Maths/math.scalar.js";
|
|
5
6
|
import { NodeGeometryContextualSources } from "../Enums/nodeGeometryContextualSources.js";
|
|
6
7
|
/**
|
|
@@ -13,6 +14,8 @@ export class NoiseBlock extends NodeGeometryBlock {
|
|
|
13
14
|
*/
|
|
14
15
|
constructor(name) {
|
|
15
16
|
super(name);
|
|
17
|
+
this.registerInput("offset", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
|
|
18
|
+
this.registerInput("scale", NodeGeometryBlockConnectionPointTypes.Float, true, 1);
|
|
16
19
|
this.registerInput("octaves", NodeGeometryBlockConnectionPointTypes.Float, true, 2, 0, 16);
|
|
17
20
|
this.registerInput("roughness", NodeGeometryBlockConnectionPointTypes.Float, true, 0.5, 0, 1);
|
|
18
21
|
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Float);
|
|
@@ -24,17 +27,29 @@ export class NoiseBlock extends NodeGeometryBlock {
|
|
|
24
27
|
getClassName() {
|
|
25
28
|
return "NoiseBlock";
|
|
26
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the offset input component
|
|
32
|
+
*/
|
|
33
|
+
get offset() {
|
|
34
|
+
return this._inputs[0];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the scale input component
|
|
38
|
+
*/
|
|
39
|
+
get scale() {
|
|
40
|
+
return this._inputs[1];
|
|
41
|
+
}
|
|
27
42
|
/**
|
|
28
43
|
* Gets the octaves input component
|
|
29
44
|
*/
|
|
30
45
|
get octaves() {
|
|
31
|
-
return this._inputs[
|
|
46
|
+
return this._inputs[2];
|
|
32
47
|
}
|
|
33
48
|
/**
|
|
34
49
|
* Gets the roughtness input component
|
|
35
50
|
*/
|
|
36
51
|
get roughness() {
|
|
37
|
-
return this._inputs[
|
|
52
|
+
return this._inputs[3];
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
55
|
* Gets the geometry output component
|
|
@@ -112,7 +127,8 @@ export class NoiseBlock extends NodeGeometryBlock {
|
|
|
112
127
|
* @returns a value between 0 and 1
|
|
113
128
|
* @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533
|
|
114
129
|
*/
|
|
115
|
-
noise(octaves, roughness,
|
|
130
|
+
noise(octaves, roughness, _position, offset, scale) {
|
|
131
|
+
const position = new Vector3(_position.x + offset.x * scale, _position.y + offset.y * scale, _position.z + offset.z * scale);
|
|
116
132
|
let fscale = 1.0;
|
|
117
133
|
let amp = 1.0;
|
|
118
134
|
let maxamp = 0.0;
|
|
@@ -141,7 +157,9 @@ export class NoiseBlock extends NodeGeometryBlock {
|
|
|
141
157
|
const position = state.getContextualValue(NodeGeometryContextualSources.Positions);
|
|
142
158
|
const octaves = this.octaves.getConnectedValue(state);
|
|
143
159
|
const roughness = this.roughness.getConnectedValue(state);
|
|
144
|
-
|
|
160
|
+
const offset = this.offset.getConnectedValue(state);
|
|
161
|
+
const scale = this.scale.getConnectedValue(state);
|
|
162
|
+
return this.noise(octaves, roughness, position, offset, scale);
|
|
145
163
|
};
|
|
146
164
|
}
|
|
147
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noiseBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/noiseBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAC7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3F,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9F,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI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ometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { Vector3 } from \"../../../Maths/math.vector\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to get a noise value\r\n */\r\nexport class NoiseBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new NoiseBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"octaves\", NodeGeometryBlockConnectionPointTypes.Float, true, 2, 0, 16);\r\n this.registerInput(\"roughness\", NodeGeometryBlockConnectionPointTypes.Float, true, 0.5, 0, 1);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"NoiseBlock\";\r\n }\r\n\r\n /**\r\n * Gets the octaves input component\r\n */\r\n public get octaves(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the roughtness input component\r\n */\r\n public get roughness(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _negateIf(value: number, condition: number) {\r\n return condition !== 0 ? -value : value;\r\n }\r\n\r\n private _noiseGrad(hash: number, x: number, y: number, z: number) {\r\n const h = hash & 15;\r\n const u = h < 8 ? x : y;\r\n const vt = h === 12 || h == 14 ? x : z;\r\n const v = h < 4 ? y : vt;\r\n return this._negateIf(u, h & u) + this._negateIf(v, h & 2);\r\n }\r\n\r\n private _fade(t: number) {\r\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\r\n }\r\n\r\n private _hashBitRotate(x: number, k: number) {\r\n return (x << k) | (x >> (32 - k));\r\n }\r\n\r\n private _hash(kx: number, ky: number, kz: number) {\r\n let a: number, b: number, c: number;\r\n a = b = c = 0xdeadbeef + (3 << 2) + 13;\r\n\r\n c += kz;\r\n b += ky;\r\n a += kx;\r\n\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 14);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 11);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 25);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 16);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 4);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 14);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 24);\r\n\r\n return c;\r\n }\r\n\r\n private _mix(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, x: number, y: number, z: number) {\r\n const x1 = 1.0 - x;\r\n const y1 = 1.0 - y;\r\n const z1 = 1.0 - z;\r\n return z1 * (y1 * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x)) + z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x));\r\n }\r\n\r\n private _perlinNoise(position: Vector3) {\r\n const X = (position.x | 0) - (position.x < 0 ? 1 : 0);\r\n const Y = (position.y | 0) - (position.y < 0 ? 1 : 0);\r\n const Z = (position.z | 0) - (position.z < 0 ? 1 : 0);\r\n\r\n const fx = position.x - X;\r\n const fy = position.y - Y;\r\n const fz = position.z - Z;\r\n\r\n const u = this._fade(fx);\r\n const v = this._fade(fy);\r\n const w = this._fade(fz);\r\n\r\n return this._mix(\r\n this._noiseGrad(this._hash(X, Y, Z), fx, fy, fz),\r\n this._noiseGrad(this._hash(X + 1, Y, Z), fx - 1, fy, fz),\r\n this._noiseGrad(this._hash(X, Y + 1, Z), fx, fy - 1, fz),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z), fx - 1, fy - 1, fz),\r\n this._noiseGrad(this._hash(X, Y, Z + 1), fx, fy, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y, Z + 1), fx - 1, fy, fz - 1),\r\n this._noiseGrad(this._hash(X, Y + 1, Z + 1), fx, fy - 1, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z + 1), fx - 1, fy - 1, fz - 1),\r\n u,\r\n v,\r\n w\r\n );\r\n }\r\n\r\n private _perlinSigned(position: Vector3) {\r\n return this._perlinNoise(position) * 0.982;\r\n }\r\n\r\n private _perlin(position: Vector3) {\r\n return this._perlinSigned(position) / 2.0 + 0.5;\r\n }\r\n\r\n /**\r\n * Gets a perlin noise value\r\n * @param octaves\r\n * @param roughness\r\n * @param position\r\n * @returns a value between 0 and 1\r\n * @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533\r\n */\r\n noise(octaves: number, roughness: number, position: Vector3) {\r\n let fscale = 1.0;\r\n let amp = 1.0;\r\n let maxamp = 0.0;\r\n let sum = 0.0;\r\n octaves = Scalar.Clamp(octaves, 0, 15.0);\r\n const step = octaves | 0;\r\n\r\n for (let i = 0; i <= step; i++) {\r\n const t = this._perlin(position.scale(fscale));\r\n sum += t * amp;\r\n maxamp += amp;\r\n amp *= Scalar.Clamp(roughness, 0.0, 1.0);\r\n fscale *= 2.0;\r\n }\r\n\r\n const rmd = octaves - Math.floor(octaves);\r\n if (rmd == 0.0) {\r\n return sum / maxamp;\r\n }\r\n\r\n const t = this._perlin(position.scale(fscale));\r\n let sum2 = sum + t * amp;\r\n sum /= maxamp;\r\n sum2 /= maxamp + amp;\r\n return (1.0 - rmd) * sum + rmd * sum2;\r\n }\r\n\r\n protected _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n const position = state.getContextualValue(NodeGeometryContextualSources.Positions) as Vector3;\r\n const octaves = this.octaves.getConnectedValue(state);\r\n const roughness = this.roughness.getConnectedValue(state);\r\n\r\n return this.noise(octaves, roughness, position);\r\n };\r\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Y,CAAC;YAC9F,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACtD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAE1D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAY,CAAC;YAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACnE,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { Vector3 } from \"../../../Maths/math.vector\";\r\nimport { Scalar } from \"../../../Maths/math.scalar\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Block used to get a noise value\r\n */\r\nexport class NoiseBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new NoiseBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"offset\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scale\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\r\n\r\n this.registerInput(\"octaves\", NodeGeometryBlockConnectionPointTypes.Float, true, 2, 0, 16);\r\n this.registerInput(\"roughness\", NodeGeometryBlockConnectionPointTypes.Float, true, 0.5, 0, 1);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"NoiseBlock\";\r\n }\r\n\r\n /**\r\n * Gets the offset input component\r\n */\r\n public get offset(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the octaves input component\r\n */\r\n public get octaves(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the roughtness input component\r\n */\r\n public get roughness(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _negateIf(value: number, condition: number) {\r\n return condition !== 0 ? -value : value;\r\n }\r\n\r\n private _noiseGrad(hash: number, x: number, y: number, z: number) {\r\n const h = hash & 15;\r\n const u = h < 8 ? x : y;\r\n const vt = h === 12 || h == 14 ? x : z;\r\n const v = h < 4 ? y : vt;\r\n return this._negateIf(u, h & u) + this._negateIf(v, h & 2);\r\n }\r\n\r\n private _fade(t: number) {\r\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\r\n }\r\n\r\n private _hashBitRotate(x: number, k: number) {\r\n return (x << k) | (x >> (32 - k));\r\n }\r\n\r\n private _hash(kx: number, ky: number, kz: number) {\r\n let a: number, b: number, c: number;\r\n a = b = c = 0xdeadbeef + (3 << 2) + 13;\r\n\r\n c += kz;\r\n b += ky;\r\n a += kx;\r\n\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 14);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 11);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 25);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 16);\r\n a ^= c;\r\n a -= this._hashBitRotate(c, 4);\r\n b ^= a;\r\n b -= this._hashBitRotate(a, 14);\r\n c ^= b;\r\n c -= this._hashBitRotate(b, 24);\r\n\r\n return c;\r\n }\r\n\r\n private _mix(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, x: number, y: number, z: number) {\r\n const x1 = 1.0 - x;\r\n const y1 = 1.0 - y;\r\n const z1 = 1.0 - z;\r\n return z1 * (y1 * (v0 * x1 + v1 * x) + y * (v2 * x1 + v3 * x)) + z * (y1 * (v4 * x1 + v5 * x) + y * (v6 * x1 + v7 * x));\r\n }\r\n\r\n private _perlinNoise(position: Vector3) {\r\n const X = (position.x | 0) - (position.x < 0 ? 1 : 0);\r\n const Y = (position.y | 0) - (position.y < 0 ? 1 : 0);\r\n const Z = (position.z | 0) - (position.z < 0 ? 1 : 0);\r\n\r\n const fx = position.x - X;\r\n const fy = position.y - Y;\r\n const fz = position.z - Z;\r\n\r\n const u = this._fade(fx);\r\n const v = this._fade(fy);\r\n const w = this._fade(fz);\r\n\r\n return this._mix(\r\n this._noiseGrad(this._hash(X, Y, Z), fx, fy, fz),\r\n this._noiseGrad(this._hash(X + 1, Y, Z), fx - 1, fy, fz),\r\n this._noiseGrad(this._hash(X, Y + 1, Z), fx, fy - 1, fz),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z), fx - 1, fy - 1, fz),\r\n this._noiseGrad(this._hash(X, Y, Z + 1), fx, fy, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y, Z + 1), fx - 1, fy, fz - 1),\r\n this._noiseGrad(this._hash(X, Y + 1, Z + 1), fx, fy - 1, fz - 1),\r\n this._noiseGrad(this._hash(X + 1, Y + 1, Z + 1), fx - 1, fy - 1, fz - 1),\r\n u,\r\n v,\r\n w\r\n );\r\n }\r\n\r\n private _perlinSigned(position: Vector3) {\r\n return this._perlinNoise(position) * 0.982;\r\n }\r\n\r\n private _perlin(position: Vector3) {\r\n return this._perlinSigned(position) / 2.0 + 0.5;\r\n }\r\n\r\n /**\r\n * Gets a perlin noise value\r\n * @param octaves\r\n * @param roughness\r\n * @param position\r\n * @returns a value between 0 and 1\r\n * @see Based on https://github.com/blender/blender/blob/main/source/blender/blenlib/intern/noise.cc#L533\r\n */\r\n noise(octaves: number, roughness: number, _position: Vector3, offset: Vector3, scale: number) {\r\n const position = new Vector3(_position.x + offset.x * scale, _position.y + offset.y * scale, _position.z + offset.z * scale);\r\n\r\n let fscale = 1.0;\r\n let amp = 1.0;\r\n let maxamp = 0.0;\r\n let sum = 0.0;\r\n octaves = Scalar.Clamp(octaves, 0, 15.0);\r\n const step = octaves | 0;\r\n\r\n for (let i = 0; i <= step; i++) {\r\n const t = this._perlin(position.scale(fscale));\r\n sum += t * amp;\r\n maxamp += amp;\r\n amp *= Scalar.Clamp(roughness, 0.0, 1.0);\r\n fscale *= 2.0;\r\n }\r\n\r\n const rmd = octaves - Math.floor(octaves);\r\n if (rmd == 0.0) {\r\n return sum / maxamp;\r\n }\r\n\r\n const t = this._perlin(position.scale(fscale));\r\n let sum2 = sum + t * amp;\r\n sum /= maxamp;\r\n sum2 /= maxamp + amp;\r\n return (1.0 - rmd) * sum + rmd * sum2;\r\n }\r\n\r\n protected _buildBlock() {\r\n this.output._storedFunction = (state) => {\r\n const position = state.getContextualValue(NodeGeometryContextualSources.Positions) as Vector3;\r\n const octaves = this.octaves.getConnectedValue(state);\r\n const roughness = this.roughness.getConnectedValue(state);\r\n\r\n const offset = this.offset.getConnectedValue(state) as Vector3;\r\n const scale = this.scale.getConnectedValue(state);\r\n\r\n return this.noise(octaves, roughness, position, offset, scale);\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NoiseBlock\", NoiseBlock);\r\n"]}
|
|
@@ -29,5 +29,7 @@ export var NodeGeometryContextualSources;
|
|
|
29
29
|
NodeGeometryContextualSources[NodeGeometryContextualSources["VertexID"] = 11] = "VertexID";
|
|
30
30
|
/** FaceID */
|
|
31
31
|
NodeGeometryContextualSources[NodeGeometryContextualSources["FaceID"] = 12] = "FaceID";
|
|
32
|
+
/** GeometryID */
|
|
33
|
+
NodeGeometryContextualSources[NodeGeometryContextualSources["GeometryID"] = 13] = "GeometryID";
|
|
32
34
|
})(NodeGeometryContextualSources || (NodeGeometryContextualSources = {}));
|
|
33
35
|
//# sourceMappingURL=nodeGeometryContextualSources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeGeometryContextualSources.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Enums/nodeGeometryContextualSources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"nodeGeometryContextualSources.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Enums/nodeGeometryContextualSources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,6BA6BX;AA7BD,WAAY,6BAA6B;IACrC,WAAW;IACX,iFAAa,CAAA;IACb,gBAAgB;IAChB,2FAAkB,CAAA;IAClB,cAAc;IACd,uFAAgB,CAAA;IAChB,eAAe;IACf,yFAAiB,CAAA;IACjB,SAAS;IACT,6EAAW,CAAA;IACX,UAAU;IACV,+EAAY,CAAA;IACZ,UAAU;IACV,+EAAY,CAAA;IACZ,UAAU;IACV,+EAAY,CAAA;IACZ,UAAU;IACV,+EAAY,CAAA;IACZ,UAAU;IACV,+EAAY,CAAA;IACZ,aAAa;IACb,sFAAe,CAAA;IACf,eAAe;IACf,0FAAiB,CAAA;IACjB,aAAa;IACb,sFAAe,CAAA;IACf,iBAAiB;IACjB,8FAAmB,CAAA;AACvB,CAAC,EA7BW,6BAA6B,KAA7B,6BAA6B,QA6BxC","sourcesContent":["/**\r\n * Defines the kind of contextual sources for node geometry\r\n */\r\nexport enum NodeGeometryContextualSources {\r\n /** None */\r\n None = 0x0000,\r\n /** Positions */\r\n Positions = 0x0001,\r\n /** Normals */\r\n Normals = 0x0002,\r\n /** Tangents */\r\n Tangents = 0x0003,\r\n /** UV */\r\n UV = 0x0004,\r\n /** UV2 */\r\n UV2 = 0x0005,\r\n /** UV3 */\r\n UV3 = 0x0006,\r\n /** UV4 */\r\n UV4 = 0x0007,\r\n /** UV5 */\r\n UV5 = 0x0008,\r\n /** UV6 */\r\n UV6 = 0x0009,\r\n /** Colors */\r\n Colors = 0x000a,\r\n /** VertexID */\r\n VertexID = 0x000b,\r\n /** FaceID */\r\n FaceID = 0x000c,\r\n /** GeometryID */\r\n GeometryID = 0x000d,\r\n}\r\n"]}
|
package/Meshes/Node/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export * from "./Blocks/Matrices/alignBlock";
|
|
|
45
45
|
export * from "./Blocks/Matrices/translationBlock";
|
|
46
46
|
export * from "./Blocks/Instances/instantiateOnVerticesBlock";
|
|
47
47
|
export * from "./Blocks/Instances/instantiateOnFacesBlock";
|
|
48
|
+
export * from "./Blocks/Instances/instantiateOnVolumeBlock";
|
|
48
49
|
export * from "./Blocks/intFloatConverterBlock";
|
|
49
50
|
export * from "./Blocks/debugBlock";
|
|
50
51
|
export * from "./Blocks/Teleport/teleportInBlock";
|
package/Meshes/Node/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export * from "./Blocks/Matrices/alignBlock.js";
|
|
|
45
45
|
export * from "./Blocks/Matrices/translationBlock.js";
|
|
46
46
|
export * from "./Blocks/Instances/instantiateOnVerticesBlock.js";
|
|
47
47
|
export * from "./Blocks/Instances/instantiateOnFacesBlock.js";
|
|
48
|
+
export * from "./Blocks/Instances/instantiateOnVolumeBlock.js";
|
|
48
49
|
export * from "./Blocks/intFloatConverterBlock.js";
|
|
49
50
|
export * from "./Blocks/debugBlock.js";
|
|
50
51
|
export * from "./Blocks/Teleport/teleportInBlock.js";
|