@babylonjs/core 6.16.2 → 6.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Audio/audioEngine.d.ts +1 -1
- package/Audio/audioEngine.js +24 -13
- package/Audio/audioEngine.js.map +1 -1
- package/Bones/skeleton.d.ts +3 -1
- package/Bones/skeleton.js +11 -2
- package/Bones/skeleton.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +26 -1
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +1 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/greasedLinePluginMaterial.d.ts +7 -2
- package/Materials/greasedLinePluginMaterial.js +46 -21
- package/Materials/greasedLinePluginMaterial.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/Sources/meshBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js +6 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCollectionBlock.d.ts +76 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js +163 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryInfoBlock.d.ts +43 -0
- package/Meshes/Node/Blocks/geometryInfoBlock.js +100 -0
- package/Meshes/Node/Blocks/geometryInfoBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +2 -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 +5 -1
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js +4 -0
- package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
- package/Meshes/Node/index.d.ts +3 -0
- package/Meshes/Node/index.js +3 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/Node/nodeGeometry.d.ts +7 -0
- package/Meshes/Node/nodeGeometry.js +17 -0
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.d.ts +8 -3
- package/Meshes/Node/nodeGeometryBlock.js +24 -5
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +8 -0
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +13 -0
- package/Meshes/mesh.vertexData.js +14 -0
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/transformNode.js +7 -3
- package/Meshes/transformNode.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/Shaders/gpuRenderParticles.vertex.js +5 -5
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/particles.vertex.js +5 -5
- package/Shaders/particles.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -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":";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;AAEtG,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAc3D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAjBR,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;QAEjC;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU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;;;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,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;IAC/D,CAAC;CACJ;AA/MU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,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"]}
|
|
@@ -23,6 +23,10 @@ export declare class MeshBlock extends NodeGeometryBlock {
|
|
|
23
23
|
* @returns the class name
|
|
24
24
|
*/
|
|
25
25
|
getClassName(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets a boolean indicating if the block is using cached data
|
|
28
|
+
*/
|
|
29
|
+
get isUsingCachedData(): boolean;
|
|
26
30
|
/**
|
|
27
31
|
* Gets the geometry output component
|
|
28
32
|
*/
|
|
@@ -31,6 +31,12 @@ export class MeshBlock extends NodeGeometryBlock {
|
|
|
31
31
|
getClassName() {
|
|
32
32
|
return "MeshBlock";
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets a boolean indicating if the block is using cached data
|
|
36
|
+
*/
|
|
37
|
+
get isUsingCachedData() {
|
|
38
|
+
return !this.mesh && !!this._cachedVertexData;
|
|
39
|
+
}
|
|
34
40
|
/**
|
|
35
41
|
* Gets the geometry output component
|
|
36
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Sources/meshBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5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YACd,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,mBAAmB,CAAC,gBAAgB,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;aAC1G;iBAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC/B,mBAAmB,CAAC,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;aAC7E;SACJ;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,gBAAgB,EAAE;YACtC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;SACnF;IACL,CAAC;CACJ;AAED,aAAa,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { Nullable } from \"../../../../types\";\r\n\r\n/**\r\n * Defines a block used to generate a user defined mesh geometry data\r\n */\r\nexport class MeshBlock extends NodeGeometryBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"MeshBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this._mesh) {\r\n if (this._cachedVertexData) {\r\n this.geometry._storedValue = this._cachedVertexData.clone();\r\n } else {\r\n this.geometry._storedValue = null;\r\n }\r\n return;\r\n }\r\n\r\n this.geometry._storedValue = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @param saveMeshData defines a boolean indicating that mesh data must be saved as well\r\n * @returns the serialized block object\r\n */\r\n public serialize(saveMeshData?: boolean): any {\r\n const serializationObject = super.serialize();\r\n\r\n if (saveMeshData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\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 if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshBlock\", MeshBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"meshBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Sources/meshBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,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AiB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,YAAsB;QACnC,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,IAAI,YAAY,EAAE;YACd,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,mBAAmB,CAAC,gBAAgB,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;aAC1G;iBAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC/B,mBAAmB,CAAC,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;aAC7E;SACJ;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,gBAAgB,EAAE;YACtC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;SACnF;IACL,CAAC;CACJ;AAED,aAAa,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { Nullable } from \"../../../../types\";\r\n\r\n/**\r\n * Defines a block used to generate a user defined mesh geometry data\r\n */\r\nexport class MeshBlock extends NodeGeometryBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"MeshBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock() {\r\n if (!this._mesh) {\r\n if (this._cachedVertexData) {\r\n this.geometry._storedValue = this._cachedVertexData.clone();\r\n } else {\r\n this.geometry._storedValue = null;\r\n }\r\n return;\r\n }\r\n\r\n this.geometry._storedValue = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @param saveMeshData defines a boolean indicating that mesh data must be saved as well\r\n * @returns the serialized block object\r\n */\r\n public serialize(saveMeshData?: boolean): any {\r\n const serializationObject = super.serialize();\r\n\r\n if (saveMeshData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\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 if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshBlock\", MeshBlock);\r\n"]}
|
|
@@ -50,6 +50,7 @@ export class TeleportInBlock extends NodeGeometryBlock {
|
|
|
50
50
|
endpoint._entryPoint = this;
|
|
51
51
|
endpoint._outputs[0]._typeConnectionSource = this._inputs[0];
|
|
52
52
|
endpoint._tempEntryPointUniqueId = null;
|
|
53
|
+
endpoint.name = "> " + this.name;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* Remove enpoint from this block
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teleportInBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Teleport/teleportInBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAGlD,0CAA0C;IAC1C,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZR,eAAU,GAAuB,EAAE,CAAC;QAcxC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAEM,SAAS,CAAC,WAAqB,EAAE,aAAkC;QACtE,IAAI,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAE7D,KAAK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AAG,IAAI,CAAC;SAC/B;IACL,CAAC;IAES,WAAW;QACjB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE;YACpC,QAAQ,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;gBACxC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC;SACL;IACL,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { TeleportOutBlock } from \"./teleportOutBlock\";\r\n\r\n/**\r\n * Defines a block used to teleport a value to an endpoint\r\n */\r\nexport class TeleportInBlock extends NodeGeometryBlock {\r\n private _endpoints: TeleportOutBlock[] = [];\r\n\r\n /** Gets the list of attached endpoints */\r\n public get endpoints() {\r\n return this._endpoints;\r\n }\r\n\r\n /**\r\n * Create a new TeleportInBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"input\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"TeleportInBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n public _dumpCode(uniqueNames: string[], alreadyDumped: NodeGeometryBlock[]) {\r\n let codeString = super._dumpCode(uniqueNames, alreadyDumped);\r\n\r\n for (const endpoint of this.endpoints) {\r\n if (alreadyDumped.indexOf(endpoint) === -1) {\r\n codeString += endpoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Add an enpoint to this block\r\n * @param endpoint define the endpoint to attach to\r\n */\r\n public attachToEndpoint(endpoint: TeleportOutBlock) {\r\n endpoint.detach();\r\n\r\n this._endpoints.push(endpoint);\r\n endpoint._entryPoint = this;\r\n endpoint._outputs[0]._typeConnectionSource = this._inputs[0];\r\n endpoint._tempEntryPointUniqueId = null;\r\n endpoint.name = \"> \" + this.name;\r\n }\r\n\r\n /**\r\n * Remove enpoint from this block\r\n * @param endpoint define the endpoint to remove\r\n */\r\n public detachFromEndpoint(endpoint: TeleportOutBlock) {\r\n const index = this._endpoints.indexOf(endpoint);\r\n\r\n if (index !== -1) {\r\n this._endpoints.splice(index, 1);\r\n endpoint._outputs[0]._typeConnectionSource = null;\r\n endpoint._entryPoint = null;\r\n }\r\n }\r\n\r\n protected _buildBlock() {\r\n for (const endpoint of this._endpoints) {\r\n endpoint.output._storedFunction = (state) => {\r\n return this.input.getConnectedValue(state);\r\n };\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.TeleportInBlock\", TeleportInBlock);\r\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometryBuildState } from "../nodeGeometryBuildState";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to randomly pick a geometry from a collection
|
|
6
|
+
*/
|
|
7
|
+
export declare class GeometryCollectionBlock extends NodeGeometryBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
10
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
11
|
+
*/
|
|
12
|
+
evaluateContext: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new GeometryCollectionBlock
|
|
15
|
+
* @param name defines the block name
|
|
16
|
+
*/
|
|
17
|
+
constructor(name: string);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current class name
|
|
20
|
+
* @returns the class name
|
|
21
|
+
*/
|
|
22
|
+
getClassName(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the geometry0 input component
|
|
25
|
+
*/
|
|
26
|
+
get geometry0(): NodeGeometryConnectionPoint;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the geometry1 input component
|
|
29
|
+
*/
|
|
30
|
+
get geometry1(): NodeGeometryConnectionPoint;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the geometry2 input component
|
|
33
|
+
*/
|
|
34
|
+
get geometry2(): NodeGeometryConnectionPoint;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the geometry3 input component
|
|
37
|
+
*/
|
|
38
|
+
get geometry3(): NodeGeometryConnectionPoint;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the geometry4 input component
|
|
41
|
+
*/
|
|
42
|
+
get geometry4(): NodeGeometryConnectionPoint;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the geometry5 input component
|
|
45
|
+
*/
|
|
46
|
+
get geometry5(): NodeGeometryConnectionPoint;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the geometry6 input component
|
|
49
|
+
*/
|
|
50
|
+
get geometry6(): NodeGeometryConnectionPoint;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the geometry7 input component
|
|
53
|
+
*/
|
|
54
|
+
get geometry7(): NodeGeometryConnectionPoint;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the geometry8 input component
|
|
57
|
+
*/
|
|
58
|
+
get geometry8(): NodeGeometryConnectionPoint;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the geometry9 input component
|
|
61
|
+
*/
|
|
62
|
+
get geometry9(): NodeGeometryConnectionPoint;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the geometry output component
|
|
65
|
+
*/
|
|
66
|
+
get output(): NodeGeometryConnectionPoint;
|
|
67
|
+
private _storeGeometry;
|
|
68
|
+
protected _buildBlock(state: NodeGeometryBuildState): void;
|
|
69
|
+
protected _dumpPropertiesCode(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Serializes this block in a JSON representation
|
|
72
|
+
* @returns the serialized block object
|
|
73
|
+
*/
|
|
74
|
+
serialize(): any;
|
|
75
|
+
_deserialize(serializationObject: any): void;
|
|
76
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { PropertyTypeForEdition, editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
|
|
6
|
+
/**
|
|
7
|
+
* Block used to randomly pick a geometry from a collection
|
|
8
|
+
*/
|
|
9
|
+
export class GeometryCollectionBlock extends NodeGeometryBlock {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new GeometryCollectionBlock
|
|
12
|
+
* @param name defines the block name
|
|
13
|
+
*/
|
|
14
|
+
constructor(name) {
|
|
15
|
+
super(name);
|
|
16
|
+
/**
|
|
17
|
+
* Gets or sets a boolean indicating that this block can evaluate context
|
|
18
|
+
* Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
|
|
19
|
+
*/
|
|
20
|
+
this.evaluateContext = true;
|
|
21
|
+
this.registerInput("geometry0", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
22
|
+
this.registerInput("geometry1", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
23
|
+
this.registerInput("geometry2", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
24
|
+
this.registerInput("geometry3", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
25
|
+
this.registerInput("geometry4", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
26
|
+
this.registerInput("geometry5", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
27
|
+
this.registerInput("geometry6", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
28
|
+
this.registerInput("geometry7", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
29
|
+
this.registerInput("geometry8", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
30
|
+
this.registerInput("geometry9", NodeGeometryBlockConnectionPointTypes.Geometry, true);
|
|
31
|
+
this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
|
|
32
|
+
this._outputs[0]._typeConnectionSource = this._inputs[0];
|
|
33
|
+
this._linkConnectionTypes(0, 1);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets the current class name
|
|
37
|
+
* @returns the class name
|
|
38
|
+
*/
|
|
39
|
+
getClassName() {
|
|
40
|
+
return "GeometryCollectionBlock";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the geometry0 input component
|
|
44
|
+
*/
|
|
45
|
+
get geometry0() {
|
|
46
|
+
return this._inputs[0];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets the geometry1 input component
|
|
50
|
+
*/
|
|
51
|
+
get geometry1() {
|
|
52
|
+
return this._inputs[1];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the geometry2 input component
|
|
56
|
+
*/
|
|
57
|
+
get geometry2() {
|
|
58
|
+
return this._inputs[2];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the geometry3 input component
|
|
62
|
+
*/
|
|
63
|
+
get geometry3() {
|
|
64
|
+
return this._inputs[3];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets the geometry4 input component
|
|
68
|
+
*/
|
|
69
|
+
get geometry4() {
|
|
70
|
+
return this._inputs[4];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets the geometry5 input component
|
|
74
|
+
*/
|
|
75
|
+
get geometry5() {
|
|
76
|
+
return this._inputs[5];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets the geometry6 input component
|
|
80
|
+
*/
|
|
81
|
+
get geometry6() {
|
|
82
|
+
return this._inputs[6];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets the geometry7 input component
|
|
86
|
+
*/
|
|
87
|
+
get geometry7() {
|
|
88
|
+
return this._inputs[7];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets the geometry8 input component
|
|
92
|
+
*/
|
|
93
|
+
get geometry8() {
|
|
94
|
+
return this._inputs[8];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the geometry9 input component
|
|
98
|
+
*/
|
|
99
|
+
get geometry9() {
|
|
100
|
+
return this._inputs[9];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets the geometry output component
|
|
104
|
+
*/
|
|
105
|
+
get output() {
|
|
106
|
+
return this._outputs[0];
|
|
107
|
+
}
|
|
108
|
+
_storeGeometry(input, state, index, availables) {
|
|
109
|
+
if (input.isConnected) {
|
|
110
|
+
const vertexData = input.getConnectedValue(state);
|
|
111
|
+
vertexData.metadata = vertexData.metadata || {};
|
|
112
|
+
vertexData.metadata.collectionId = index;
|
|
113
|
+
availables.push(vertexData);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
_buildBlock(state) {
|
|
117
|
+
const func = (state) => {
|
|
118
|
+
const availables = [];
|
|
119
|
+
this._storeGeometry(this.geometry0, state, 0, availables);
|
|
120
|
+
this._storeGeometry(this.geometry1, state, 1, availables);
|
|
121
|
+
this._storeGeometry(this.geometry2, state, 2, availables);
|
|
122
|
+
this._storeGeometry(this.geometry3, state, 3, availables);
|
|
123
|
+
this._storeGeometry(this.geometry4, state, 4, availables);
|
|
124
|
+
this._storeGeometry(this.geometry5, state, 5, availables);
|
|
125
|
+
this._storeGeometry(this.geometry6, state, 6, availables);
|
|
126
|
+
this._storeGeometry(this.geometry7, state, 7, availables);
|
|
127
|
+
this._storeGeometry(this.geometry8, state, 8, availables);
|
|
128
|
+
this._storeGeometry(this.geometry9, state, 9, availables);
|
|
129
|
+
if (!availables.length) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return availables[Math.round(Math.random() * (availables.length - 1))];
|
|
133
|
+
};
|
|
134
|
+
if (this.evaluateContext) {
|
|
135
|
+
this.output._storedFunction = func;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
this.output._storedValue = func(state);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
_dumpPropertiesCode() {
|
|
142
|
+
const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
|
|
143
|
+
return codeString;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Serializes this block in a JSON representation
|
|
147
|
+
* @returns the serialized block object
|
|
148
|
+
*/
|
|
149
|
+
serialize() {
|
|
150
|
+
const serializationObject = super.serialize();
|
|
151
|
+
serializationObject.evaluateContext = this.evaluateContext;
|
|
152
|
+
return serializationObject;
|
|
153
|
+
}
|
|
154
|
+
_deserialize(serializationObject) {
|
|
155
|
+
super._deserialize(serializationObject);
|
|
156
|
+
this.evaluateContext = serializationObject.evaluateContext;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
__decorate([
|
|
160
|
+
editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
|
|
161
|
+
], GeometryCollectionBlock.prototype, "evaluateContext", void 0);
|
|
162
|
+
RegisterClass("BABYLON.GeometryCollectionBlock", GeometryCollectionBlock);
|
|
163
|
+
//# sourceMappingURL=geometryCollectionBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometryCollectionBlock.js","sourceRoot":"","sources":["../../../../../../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C,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;IAC/D,CAAC;CACJ;AA1KU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;gEAC3F;AA4KlC,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 { VertexData } from \"../../mesh.vertexData\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to randomly pick a geometry from a collection\r\n */\r\nexport class GeometryCollectionBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new GeometryCollectionBlock\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(\"geometry0\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry1\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry2\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry3\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry4\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry5\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry6\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry7\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry8\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"geometry9\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"GeometryCollectionBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry0 input component\r\n */\r\n public get geometry0(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the geometry1 input component\r\n */\r\n public get geometry1(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry2 input component\r\n */\r\n public get geometry2(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the geometry3 input component\r\n */\r\n public get geometry3(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the geometry4 input component\r\n */\r\n public get geometry4(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the geometry5 input component\r\n */\r\n public get geometry5(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry6 input component\r\n */\r\n public get geometry6(): NodeGeometryConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the geometry7 input component\r\n */\r\n public get geometry7(): NodeGeometryConnectionPoint {\r\n return this._inputs[7];\r\n }\r\n\r\n /**\r\n * Gets the geometry8 input component\r\n */\r\n public get geometry8(): NodeGeometryConnectionPoint {\r\n return this._inputs[8];\r\n }\r\n\r\n /**\r\n * Gets the geometry9 input component\r\n */\r\n public get geometry9(): NodeGeometryConnectionPoint {\r\n return this._inputs[9];\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 _storeGeometry(input: NodeGeometryConnectionPoint, state: NodeGeometryBuildState, index: number, availables: VertexData[]) {\r\n if (input.isConnected) {\r\n const vertexData = input.getConnectedValue(state) as VertexData;\r\n vertexData.metadata = vertexData.metadata || {};\r\n vertexData.metadata.collectionId = index;\r\n availables.push(vertexData);\r\n }\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n const availables: VertexData[] = [];\r\n\r\n this._storeGeometry(this.geometry0, state, 0, availables);\r\n this._storeGeometry(this.geometry1, state, 1, availables);\r\n this._storeGeometry(this.geometry2, state, 2, availables);\r\n this._storeGeometry(this.geometry3, state, 3, availables);\r\n this._storeGeometry(this.geometry4, state, 4, availables);\r\n this._storeGeometry(this.geometry5, state, 5, availables);\r\n this._storeGeometry(this.geometry6, state, 6, availables);\r\n this._storeGeometry(this.geometry7, state, 7, availables);\r\n this._storeGeometry(this.geometry8, state, 8, availables);\r\n this._storeGeometry(this.geometry9, state, 9, availables);\r\n\r\n if (!availables.length) {\r\n return null;\r\n }\r\n return availables[Math.round(Math.random() * (availables.length - 1))];\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryCollectionBlock\", GeometryCollectionBlock);\r\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
|
+
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
/**
|
|
4
|
+
* Block used to get information about a geometry
|
|
5
|
+
*/
|
|
6
|
+
export declare class GeometryInfoBlock extends NodeGeometryBlock {
|
|
7
|
+
private _currentVertexData;
|
|
8
|
+
/**
|
|
9
|
+
* Create a new GeometryInfoBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
/**
|
|
14
|
+
* Gets the current class name
|
|
15
|
+
* @returns the class name
|
|
16
|
+
*/
|
|
17
|
+
getClassName(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the geometry input component
|
|
20
|
+
*/
|
|
21
|
+
get geometry(): NodeGeometryConnectionPoint;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the geometry output component
|
|
24
|
+
*/
|
|
25
|
+
get output(): NodeGeometryConnectionPoint;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the id output component
|
|
28
|
+
*/
|
|
29
|
+
get id(): NodeGeometryConnectionPoint;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the collectionId output component
|
|
32
|
+
*/
|
|
33
|
+
get collectionId(): NodeGeometryConnectionPoint;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the verticesCount output component
|
|
36
|
+
*/
|
|
37
|
+
get verticesCount(): NodeGeometryConnectionPoint;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the facesCount output component
|
|
40
|
+
*/
|
|
41
|
+
get facesCount(): NodeGeometryConnectionPoint;
|
|
42
|
+
protected _buildBlock(): void;
|
|
43
|
+
}
|