x_ite 8.11.5 → 8.11.6
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/README.md +6 -0
- package/dist/assets/components/Annotation.js +13 -13
- package/dist/assets/components/Annotation.min.js +1 -1
- package/dist/assets/components/CADGeometry.js +13 -13
- package/dist/assets/components/CADGeometry.min.js +1 -1
- package/dist/assets/components/CubeMapTexturing.js +25 -25
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -13
- package/dist/assets/components/DIS.min.js +1 -1
- package/dist/assets/components/EventUtilities.js +9 -9
- package/dist/assets/components/EventUtilities.min.js +1 -1
- package/dist/assets/components/Geometry2D.js +19 -19
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +33 -33
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +23 -23
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +8 -8
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +26 -26
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +24 -24
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +50 -1061
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +18 -18
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +17 -17
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +37 -37
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +47 -31
- package/dist/assets/components/Text.min.js +1 -1
- package/dist/assets/components/TextureProjector.js +25 -21
- package/dist/assets/components/TextureProjector.min.js +1 -1
- package/dist/assets/components/Texturing3D.js +30 -30
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +40 -106
- package/dist/assets/components/VolumeRendering.min.js +1 -1
- package/dist/assets/components/X_ITE.js +9 -9
- package/dist/assets/components/X_ITE.min.js +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +1939 -5479
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +2 -2
- package/docs/_posts/dom-integration.md +1 -1
- package/docs/_posts/features.md +12 -10
- package/package.json +6 -1
- package/src/x_ite/Browser/Text/X3DTextContext.js +24 -8
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/VolumeRendering/VolumeStyle.fs.js +2 -2
- package/src/x_ite/Components/Core/X3DBindableNode.js +26 -0
- package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +6 -0
- package/src/x_ite/Components/Shaders/ShaderPart.js +1 -1
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +2 -2
- package/src/x_ite/Components/Shape/PhysicalMaterial.js +1 -1
- package/src/x_ite/Components/TextureProjector/TextureProjector.js +5 -5
- package/src/x_ite/Components/TextureProjector/X3DTextureProjectorNode.js +6 -2
- package/src/x_ite/Components/VolumeRendering/IsoSurfaceVolumeData.js +3 -2
- package/src/x_ite/Components/VolumeRendering/SegmentedVolumeData.js +3 -2
- package/src/x_ite/Components/VolumeRendering/VolumeData.js +3 -2
- package/src/x_ite/Execution/BindableList.js +10 -9
- package/src/x_ite/Rendering/X3DRenderObject.js +6 -3
- package/webpack.config.js +39 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* X_ITE v8.11.
|
|
1
|
+
/* X_ITE v8.11.6 */(() => { // webpackBootstrap
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
|
5
5
|
/***/ 355:
|
|
6
6
|
/***/ ((module) => {
|
|
7
7
|
|
|
8
|
-
module.exports = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
8
|
+
module.exports = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("lib/jquery");
|
|
9
9
|
|
|
10
10
|
/***/ })
|
|
11
11
|
|
|
@@ -73,22 +73,22 @@ var __webpack_exports__ = {};
|
|
|
73
73
|
// UNUSED EXPORTS: default
|
|
74
74
|
|
|
75
75
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components\")"
|
|
76
|
-
const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
76
|
+
const Components_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Components");
|
|
77
77
|
var Components_default = /*#__PURE__*/__webpack_require__.n(Components_namespaceObject);
|
|
78
78
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Fields\")"
|
|
79
|
-
const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
79
|
+
const Fields_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Fields");
|
|
80
80
|
var Fields_default = /*#__PURE__*/__webpack_require__.n(Fields_namespaceObject);
|
|
81
81
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DFieldDefinition\")"
|
|
82
|
-
const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
82
|
+
const X3DFieldDefinition_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Base/X3DFieldDefinition");
|
|
83
83
|
var X3DFieldDefinition_default = /*#__PURE__*/__webpack_require__.n(X3DFieldDefinition_namespaceObject);
|
|
84
84
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/FieldDefinitionArray\")"
|
|
85
|
-
const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
85
|
+
const FieldDefinitionArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Base/FieldDefinitionArray");
|
|
86
86
|
var FieldDefinitionArray_default = /*#__PURE__*/__webpack_require__.n(FieldDefinitionArray_namespaceObject);
|
|
87
87
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Core/X3DNode\")"
|
|
88
|
-
const X3DNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
88
|
+
const X3DNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Components/Core/X3DNode");
|
|
89
89
|
var X3DNode_default = /*#__PURE__*/__webpack_require__.n(X3DNode_namespaceObject);
|
|
90
90
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Namespace\")"
|
|
91
|
-
const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
91
|
+
const Namespace_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Namespace");
|
|
92
92
|
var Namespace_default = /*#__PURE__*/__webpack_require__.n(Namespace_namespaceObject);
|
|
93
93
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/ParticleSystems/GeometryTypes.js
|
|
94
94
|
/*******************************************************************************
|
|
@@ -155,477 +155,35 @@ const __default__ = GeometryTypes;
|
|
|
155
155
|
Namespace_default().set ("x_ite/Browser/ParticleSystems/GeometryTypes", __default__);
|
|
156
156
|
/* harmony default export */ const ParticleSystems_GeometryTypes = (__default__);
|
|
157
157
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DConstants\")"
|
|
158
|
-
const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
158
|
+
const X3DConstants_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Base/X3DConstants");
|
|
159
159
|
var X3DConstants_default = /*#__PURE__*/__webpack_require__.n(X3DConstants_namespaceObject);
|
|
160
160
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/ParticleSystems/Line3.glsl.js
|
|
161
|
-
const Line3_glsl_default_ = /* glsl*/ `
|
|
162
|
-
|
|
163
|
-
vec3 point;
|
|
164
|
-
vec3 direction;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// Line3
|
|
168
|
-
// line3 (const in vec3 point1, const in vec3 point2)
|
|
169
|
-
// {
|
|
170
|
-
// return Line3 (point1, normalize (point2 - point1));
|
|
171
|
-
// }
|
|
172
|
-
|
|
173
|
-
/* Line intersect triangle */
|
|
174
|
-
|
|
175
|
-
bool
|
|
176
|
-
intersects (const in Line3 line, const in vec3 a, const in vec3 b, const in vec3 c, out vec3 r)
|
|
177
|
-
{
|
|
178
|
-
// find vectors for two edges sharing vert0
|
|
179
|
-
vec3 edge1 = b - a;
|
|
180
|
-
vec3 edge2 = c - a;
|
|
181
|
-
|
|
182
|
-
// begin calculating determinant - also used to calculate U parameter
|
|
183
|
-
vec3 pvec = cross (line .direction, edge2);
|
|
184
|
-
|
|
185
|
-
// if determinant is near zero, ray lies in plane of triangle
|
|
186
|
-
float det = dot (edge1, pvec);
|
|
187
|
-
|
|
188
|
-
// Non culling intersection
|
|
189
|
-
|
|
190
|
-
if (det == 0.0)
|
|
191
|
-
return false;
|
|
192
|
-
|
|
193
|
-
float inv_det = 1.0 / det;
|
|
194
|
-
|
|
195
|
-
// calculate distance from vert0 to ray point
|
|
196
|
-
vec3 tvec = line .point - a;
|
|
197
|
-
|
|
198
|
-
// calculate U parameter and test bounds
|
|
199
|
-
float u = dot (tvec, pvec) * inv_det;
|
|
200
|
-
|
|
201
|
-
if (u < 0.0 || u > 1.0)
|
|
202
|
-
return false;
|
|
203
|
-
|
|
204
|
-
// prepare to test V parameter
|
|
205
|
-
vec3 qvec = cross (tvec, edge1);
|
|
206
|
-
|
|
207
|
-
// calculate V parameter and test bounds
|
|
208
|
-
float v = dot (line .direction, qvec) * inv_det;
|
|
209
|
-
|
|
210
|
-
if (v < 0.0 || u + v > 1.0)
|
|
211
|
-
return false;
|
|
212
|
-
|
|
213
|
-
r = vec3 (u, v, 1.0 - u - v);
|
|
214
|
-
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
`;
|
|
161
|
+
const Line3_glsl_default_ = /* glsl */ `struct Line3{vec3 point;vec3 direction;};bool intersects(const in Line3 line,const in vec3 a,const in vec3 b,const in vec3 c,out vec3 r){vec3 edge1=b-a;vec3 edge2=c-a;vec3 pvec=cross(line.direction,edge2);float det=dot(edge1,pvec);if(det==0.0)return false;float inv_det=1.0/det;vec3 tvec=line.point-a;float u=dot(tvec,pvec)*inv_det;if(u<0.0||u>1.0)return false;vec3 qvec=cross(tvec,edge1);float v=dot(line.direction,qvec)*inv_det;if(v<0.0||u+v>1.0)return false;r=vec3(u,v,1.0-u-v);return true;}
|
|
162
|
+
`
|
|
218
163
|
;
|
|
219
164
|
|
|
220
165
|
Namespace_default().set ("x_ite/Browser/ParticleSystems/Line3.glsl", Line3_glsl_default_);
|
|
221
166
|
/* harmony default export */ const Line3_glsl = (Line3_glsl_default_);
|
|
222
167
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/ParticleSystems/Plane3.glsl.js
|
|
223
|
-
const Plane3_glsl_default_ = /* glsl*/ `
|
|
224
|
-
|
|
225
|
-
{
|
|
226
|
-
vec3 normal;
|
|
227
|
-
float distanceFromOrigin;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
Plane3
|
|
231
|
-
plane3 (const in vec3 point, const in vec3 normal)
|
|
232
|
-
{
|
|
233
|
-
return Plane3 (normal, dot (normal, point));
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
float
|
|
237
|
-
plane_distance (const in Plane3 plane, const in vec3 point)
|
|
238
|
-
{
|
|
239
|
-
return dot (point, plane .normal) - plane .distanceFromOrigin;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/* Plane intersect line */
|
|
243
|
-
bool
|
|
244
|
-
intersects (const in Plane3 plane, const in Line3 line, out vec3 point)
|
|
245
|
-
{
|
|
246
|
-
// Check if the line is parallel to the plane.
|
|
247
|
-
float theta = dot (line .direction, plane .normal);
|
|
248
|
-
|
|
249
|
-
// Plane and line are parallel.
|
|
250
|
-
if (theta == 0.0)
|
|
251
|
-
return false;
|
|
252
|
-
|
|
253
|
-
// Plane and line are not parallel. The intersection point can be calculated now.
|
|
254
|
-
float t = (plane .distanceFromOrigin - dot (plane .normal, line .point)) / theta;
|
|
255
|
-
|
|
256
|
-
point = line .point + line .direction * t;
|
|
257
|
-
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/* Find find the first point that is farther to the plane than value. */
|
|
262
|
-
// int
|
|
263
|
-
// upper_bound (const in vec4 points [ARRAY_SIZE], in int count, const in float value, const in Plane3 plane)
|
|
264
|
-
// {
|
|
265
|
-
// int first = 0;
|
|
266
|
-
// int step = 0;
|
|
267
|
-
|
|
268
|
-
// while (count > 0)
|
|
269
|
-
// {
|
|
270
|
-
// int index = first;
|
|
271
|
-
|
|
272
|
-
// step = count >> 1;
|
|
273
|
-
|
|
274
|
-
// index += step;
|
|
275
|
-
|
|
276
|
-
// if (value < plane_distance (plane, points [index] .xyz))
|
|
277
|
-
// {
|
|
278
|
-
// count = step;
|
|
279
|
-
// }
|
|
280
|
-
// else
|
|
281
|
-
// {
|
|
282
|
-
// first = ++ index;
|
|
283
|
-
// count -= step + 1;
|
|
284
|
-
// }
|
|
285
|
-
// }
|
|
286
|
-
|
|
287
|
-
// return first;
|
|
288
|
-
// }
|
|
289
|
-
|
|
290
|
-
/* CombSort: sort points in distance to a plane. */
|
|
291
|
-
void
|
|
292
|
-
sort (inout vec4 points [ARRAY_SIZE], const in int count, const in Plane3 plane)
|
|
293
|
-
{
|
|
294
|
-
const float shrink = 1.0 / 1.3;
|
|
295
|
-
|
|
296
|
-
int gap = count;
|
|
297
|
-
bool exchanged = true;
|
|
298
|
-
|
|
299
|
-
while (exchanged)
|
|
300
|
-
{
|
|
301
|
-
gap = int (float (gap) * shrink);
|
|
302
|
-
|
|
303
|
-
if (gap <= 1)
|
|
304
|
-
{
|
|
305
|
-
exchanged = false;
|
|
306
|
-
gap = 1;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
for (int i = 0, l = count - gap; i < l; ++ i)
|
|
310
|
-
{
|
|
311
|
-
int j = gap + i;
|
|
312
|
-
|
|
313
|
-
if (plane_distance (plane, points [i] .xyz) > plane_distance (plane, points [j] .xyz))
|
|
314
|
-
{
|
|
315
|
-
vec4 tmp1 = points [i];
|
|
316
|
-
points [i] = points [j];
|
|
317
|
-
points [j] = tmp1;
|
|
318
|
-
|
|
319
|
-
exchanged = true;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
// /* CombSort: sort points and normals in distance to a plane. */
|
|
327
|
-
// void
|
|
328
|
-
// sort (inout vec4 points [ARRAY_SIZE], inout vec3 normals [ARRAY_SIZE], const in int count, const in Plane3 plane)
|
|
329
|
-
// {
|
|
330
|
-
// const float shrink = 1.0 / 1.3;
|
|
331
|
-
|
|
332
|
-
// int gap = count;
|
|
333
|
-
// bool exchanged = true;
|
|
334
|
-
|
|
335
|
-
// while (exchanged)
|
|
336
|
-
// {
|
|
337
|
-
// gap = int (float (gap) * shrink);
|
|
338
|
-
|
|
339
|
-
// if (gap <= 1)
|
|
340
|
-
// {
|
|
341
|
-
// exchanged = false;
|
|
342
|
-
// gap = 1;
|
|
343
|
-
// }
|
|
344
|
-
|
|
345
|
-
// for (int i = 0, l = count - gap; i < l; ++ i)
|
|
346
|
-
// {
|
|
347
|
-
// int j = gap + i;
|
|
348
|
-
|
|
349
|
-
// if (plane_distance (plane, points [i] .xyz) > plane_distance (plane, points [j] .xyz))
|
|
350
|
-
// {
|
|
351
|
-
// vec4 tmp1 = points [i];
|
|
352
|
-
// points [i] = points [j];
|
|
353
|
-
// points [j] = tmp1;
|
|
354
|
-
|
|
355
|
-
// vec3 tmp2 = normals [i];
|
|
356
|
-
// normals [i] = normals [j];
|
|
357
|
-
// normals [j] = tmp2;
|
|
358
|
-
|
|
359
|
-
// exchanged = true;
|
|
360
|
-
// }
|
|
361
|
-
// }
|
|
362
|
-
// }
|
|
363
|
-
// }
|
|
364
|
-
|
|
365
|
-
int
|
|
366
|
-
min_index (const in vec4 points [ARRAY_SIZE], const in int count, const in float value, const in Plane3 plane)
|
|
367
|
-
{
|
|
368
|
-
int index = -1;
|
|
369
|
-
float dist = 1000000.0;
|
|
370
|
-
|
|
371
|
-
for (int i = 0; i < count; ++ i)
|
|
372
|
-
{
|
|
373
|
-
float d = plane_distance (plane, points [i] .xyz);
|
|
374
|
-
|
|
375
|
-
if (d >= value && d < dist)
|
|
376
|
-
{
|
|
377
|
-
dist = d;
|
|
378
|
-
index = i;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return index;
|
|
383
|
-
}
|
|
384
|
-
`;
|
|
168
|
+
const Plane3_glsl_default_ = /* glsl */ `struct Plane3{vec3 normal;float distanceFromOrigin;};Plane3 plane3(const in vec3 point,const in vec3 normal){return Plane3(normal,dot(normal,point));}float plane_distance(const in Plane3 plane,const in vec3 point){return dot(point,plane.normal)-plane.distanceFromOrigin;}bool intersects(const in Plane3 plane,const in Line3 line,out vec3 point){float theta=dot(line.direction,plane.normal);if(theta==0.0)return false;float t=(plane.distanceFromOrigin-dot(plane.normal,line.point))/theta;point=line.point+line.direction*t;return true;}void sort(inout vec4 points[ARRAY_SIZE],const in int count,const in Plane3 plane){const float shrink=1.0/1.3;int gap=count;bool exchanged=true;while(exchanged){gap=int(float(gap)*shrink);if(gap<=1){exchanged=false;gap=1;}for(int i=0,l=count-gap;i<l;++i){int j=gap+i;if(plane_distance(plane,points[i].xyz)>plane_distance(plane,points[j].xyz)){vec4 tmp1=points[i];points[i]=points[j];points[j]=tmp1;exchanged=true;}}}}int min_index(const in vec4 points[ARRAY_SIZE],const in int count,const in float value,const in Plane3 plane){int index=-1;float dist=1000000.0;for(int i=0;i<count;++i){float d=plane_distance(plane,points[i].xyz);if(d>=value&&d<dist){dist=d;index=i;}}return index;}
|
|
169
|
+
`
|
|
385
170
|
;
|
|
386
171
|
|
|
387
172
|
Namespace_default().set ("x_ite/Browser/ParticleSystems/Plane3.glsl", Plane3_glsl_default_);
|
|
388
173
|
/* harmony default export */ const Plane3_glsl = (Plane3_glsl_default_);
|
|
389
174
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/ParticleSystems/Box3.glsl.js
|
|
390
|
-
const Box3_glsl_default_ = /* glsl*/ `
|
|
391
|
-
|
|
392
|
-
intersects (const in vec3 min, const in vec3 max, const in Line3 line)
|
|
393
|
-
{
|
|
394
|
-
vec3 intersection;
|
|
395
|
-
|
|
396
|
-
// front
|
|
397
|
-
|
|
398
|
-
if (intersects (plane3 (max, vec3 (0.0, 0.0, 1.0)), line, intersection))
|
|
399
|
-
{
|
|
400
|
-
if (all (greaterThanEqual (vec4 (intersection .xy, max .xy), vec4 (min .xy, intersection .xy))))
|
|
401
|
-
return true;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// back
|
|
405
|
-
|
|
406
|
-
if (intersects (plane3 (min, vec3 (0.0, 0.0, -1.0)), line, intersection))
|
|
407
|
-
{
|
|
408
|
-
if (all (greaterThanEqual (vec4 (intersection .xy, max .xy), vec4 (min .xy, intersection .xy))))
|
|
409
|
-
return true;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// top
|
|
413
|
-
|
|
414
|
-
if (intersects (plane3 (max, vec3 (0.0, 1.0, 0.0)), line, intersection))
|
|
415
|
-
{
|
|
416
|
-
if (all (greaterThanEqual (vec4 (intersection .xz, max .xz), vec4 (min .xz, intersection .xz))))
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// bottom
|
|
421
|
-
|
|
422
|
-
if (intersects (plane3 (min, vec3 (0.0, -1.0, 0.0)), line, intersection))
|
|
423
|
-
{
|
|
424
|
-
if (all (greaterThanEqual (vec4 (intersection .xz, max .xz), vec4 (min .xz, intersection .xz))))
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// right
|
|
429
|
-
|
|
430
|
-
if (intersects (plane3 (max, vec3 (1.0, 0.0, 0.0)), line, intersection))
|
|
431
|
-
{
|
|
432
|
-
if (all (greaterThanEqual (vec4 (intersection .yz, max .yz), vec4 (min .yz, intersection .yz))))
|
|
433
|
-
return true;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
`;
|
|
175
|
+
const Box3_glsl_default_ = /* glsl */ `bool intersects(const in vec3 min,const in vec3 max,const in Line3 line){vec3 intersection;if(intersects(plane3(max,vec3(0.0,0.0,1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(min,vec3(0.0,0.0,-1.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xy,max.xy),vec4(min.xy,intersection.xy))))return true;}if(intersects(plane3(max,vec3(0.0,1.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(min,vec3(0.0,-1.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.xz,max.xz),vec4(min.xz,intersection.xz))))return true;}if(intersects(plane3(max,vec3(1.0,0.0,0.0)),line,intersection)){if(all(greaterThanEqual(vec4(intersection.yz,max.yz),vec4(min.yz,intersection.yz))))return true;}return false;}
|
|
176
|
+
`
|
|
439
177
|
;
|
|
440
178
|
|
|
441
179
|
Namespace_default().set ("x_ite/Browser/ParticleSystems/Box3.glsl", Box3_glsl_default_);
|
|
442
180
|
/* harmony default export */ const Box3_glsl = (Box3_glsl_default_);
|
|
443
181
|
;// CONCATENATED MODULE: ./src/x_ite/Browser/ParticleSystems/BVH.glsl.js
|
|
444
|
-
const BVH_glsl_default_ = /* glsl*/
|
|
445
|
-
#define
|
|
446
|
-
#define
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
int bvhNodeIndex = 0;
|
|
450
|
-
|
|
451
|
-
void
|
|
452
|
-
setBVHIndex (const in int index)
|
|
453
|
-
{
|
|
454
|
-
bvhNodeIndex = index;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
int
|
|
458
|
-
getBVHRoot (const in sampler2D volume, const in int hierarchyIndex, const in int rootIndex)
|
|
459
|
-
{
|
|
460
|
-
return int (texelFetch (volume, rootIndex, 0) .x) + hierarchyIndex;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
int
|
|
464
|
-
getBVHType (const in sampler2D volume)
|
|
465
|
-
{
|
|
466
|
-
return int (texelFetch (volume, bvhNodeIndex, 0) .x);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
vec3
|
|
470
|
-
getBVHMin (const in sampler2D volume)
|
|
471
|
-
{
|
|
472
|
-
return texelFetch (volume, bvhNodeIndex + 1, 0) .xyz;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
vec3
|
|
476
|
-
getBVHMax (const in sampler2D volume)
|
|
477
|
-
{
|
|
478
|
-
return texelFetch (volume, bvhNodeIndex + 2, 0) .xyz;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
int
|
|
482
|
-
getBVHLeft (const in sampler2D volume, const in int hierarchyIndex)
|
|
483
|
-
{
|
|
484
|
-
return int (texelFetch (volume, bvhNodeIndex, 0) .y) + hierarchyIndex;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
int
|
|
488
|
-
getBVHRight (const in sampler2D volume, const in int hierarchyIndex)
|
|
489
|
-
{
|
|
490
|
-
return int (texelFetch (volume, bvhNodeIndex, 0) .z) + hierarchyIndex;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
int
|
|
494
|
-
getBVHTriangle (const in sampler2D volume)
|
|
495
|
-
{
|
|
496
|
-
return int (texelFetch (volume, bvhNodeIndex, 0) .y);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/* Ray triangle intersection test */
|
|
500
|
-
|
|
501
|
-
int
|
|
502
|
-
getIntersections (const in sampler2D volume, const in int verticesIndex, const in int hierarchyIndex, const in int rootIndex, const in Line3 line, out vec4 points [ARRAY_SIZE])
|
|
503
|
-
{
|
|
504
|
-
int current = getBVHRoot (volume, hierarchyIndex, rootIndex);
|
|
505
|
-
int count = 0;
|
|
506
|
-
int stackIndex = -1;
|
|
507
|
-
int stack [BVH_STACK_SIZE];
|
|
508
|
-
|
|
509
|
-
while (stackIndex >= 0 || current >= 0)
|
|
510
|
-
{
|
|
511
|
-
if (current >= 0)
|
|
512
|
-
{
|
|
513
|
-
setBVHIndex (current);
|
|
514
|
-
|
|
515
|
-
if (getBVHType (volume) == BVH_NODE)
|
|
516
|
-
{
|
|
517
|
-
// Node
|
|
518
|
-
|
|
519
|
-
if (intersects (getBVHMin (volume), getBVHMax (volume), line))
|
|
520
|
-
{
|
|
521
|
-
stack [++ stackIndex] = current;
|
|
522
|
-
|
|
523
|
-
current = getBVHLeft (volume, hierarchyIndex);
|
|
524
|
-
}
|
|
525
|
-
else
|
|
526
|
-
{
|
|
527
|
-
current = -1;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
else
|
|
531
|
-
{
|
|
532
|
-
// Triangle
|
|
533
|
-
|
|
534
|
-
int t = getBVHTriangle (volume);
|
|
535
|
-
int v = verticesIndex + t;
|
|
536
|
-
vec3 r = vec3 (0.0);
|
|
537
|
-
|
|
538
|
-
vec3 a = texelFetch (volume, v, 0) .xyz;
|
|
539
|
-
vec3 b = texelFetch (volume, v + 1, 0) .xyz;
|
|
540
|
-
vec3 c = texelFetch (volume, v + 2, 0) .xyz;
|
|
541
|
-
|
|
542
|
-
if (intersects (line, a, b, c, r))
|
|
543
|
-
points [count ++] = vec4 (r .z * a + r .x * b + r .y * c, 1.0);
|
|
544
|
-
|
|
545
|
-
current = -1;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
else
|
|
549
|
-
{
|
|
550
|
-
setBVHIndex (stack [stackIndex --]);
|
|
551
|
-
|
|
552
|
-
current = getBVHRight (volume, hierarchyIndex);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
return count;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
int
|
|
560
|
-
getIntersections (const in sampler2D volume, const in int verticesIndex, const in int normalsIndex, const in int hierarchyIndex, const in int rootIndex, const in Line3 line, out vec4 points [ARRAY_SIZE], out vec3 normals [ARRAY_SIZE])
|
|
561
|
-
{
|
|
562
|
-
int current = getBVHRoot (volume, hierarchyIndex, rootIndex);
|
|
563
|
-
int count = 0;
|
|
564
|
-
int stackIndex = -1;
|
|
565
|
-
int stack [BVH_STACK_SIZE];
|
|
566
|
-
|
|
567
|
-
while (stackIndex >= 0 || current >= 0)
|
|
568
|
-
{
|
|
569
|
-
if (current >= 0)
|
|
570
|
-
{
|
|
571
|
-
setBVHIndex (current);
|
|
572
|
-
|
|
573
|
-
if (getBVHType (volume) == BVH_NODE)
|
|
574
|
-
{
|
|
575
|
-
// Node
|
|
576
|
-
|
|
577
|
-
if (intersects (getBVHMin (volume), getBVHMax (volume), line))
|
|
578
|
-
{
|
|
579
|
-
stack [++ stackIndex] = current;
|
|
580
|
-
|
|
581
|
-
current = getBVHLeft (volume, hierarchyIndex);
|
|
582
|
-
}
|
|
583
|
-
else
|
|
584
|
-
{
|
|
585
|
-
current = -1;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
else
|
|
589
|
-
{
|
|
590
|
-
// Triangle
|
|
591
|
-
|
|
592
|
-
int t = getBVHTriangle (volume);
|
|
593
|
-
int v = verticesIndex + t;
|
|
594
|
-
vec3 r = vec3 (0.0);
|
|
595
|
-
|
|
596
|
-
vec3 a = texelFetch (volume, v, 0) .xyz;
|
|
597
|
-
vec3 b = texelFetch (volume, v + 1, 0) .xyz;
|
|
598
|
-
vec3 c = texelFetch (volume, v + 2, 0) .xyz;
|
|
599
|
-
|
|
600
|
-
if (intersects (line, a, b, c, r))
|
|
601
|
-
{
|
|
602
|
-
points [count] = vec4 (r .z * a + r .x * b + r .y * c, 1.0);
|
|
603
|
-
|
|
604
|
-
int n = normalsIndex + t;
|
|
605
|
-
|
|
606
|
-
vec3 n0 = texelFetch (volume, n, 0) .xyz;
|
|
607
|
-
vec3 n1 = texelFetch (volume, n + 1, 0) .xyz;
|
|
608
|
-
vec3 n2 = texelFetch (volume, n + 2, 0) .xyz;
|
|
609
|
-
|
|
610
|
-
normals [count] = save_normalize (r .z * n0 + r .x * n1 + r .y * n2);
|
|
611
|
-
|
|
612
|
-
++ count;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
current = -1;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else
|
|
619
|
-
{
|
|
620
|
-
setBVHIndex (stack [stackIndex --]);
|
|
621
|
-
|
|
622
|
-
current = getBVHRight (volume, hierarchyIndex);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return count;
|
|
627
|
-
}
|
|
628
|
-
`;
|
|
182
|
+
const BVH_glsl_default_ = /* glsl */ `#define BVH_NODE 0
|
|
183
|
+
#define BVH_TRIANGLE 1
|
|
184
|
+
#define BVH_STACK_SIZE 32
|
|
185
|
+
int bvhNodeIndex=0;void setBVHIndex(const in int index){bvhNodeIndex=index;}int getBVHRoot(const in sampler2D volume,const in int hierarchyIndex,const in int rootIndex){return int(texelFetch(volume,rootIndex,0).x)+hierarchyIndex;}int getBVHType(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).x);}vec3 getBVHMin(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+1,0).xyz;}vec3 getBVHMax(const in sampler2D volume){return texelFetch(volume,bvhNodeIndex+2,0).xyz;}int getBVHLeft(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).y)+hierarchyIndex;}int getBVHRight(const in sampler2D volume,const in int hierarchyIndex){return int(texelFetch(volume,bvhNodeIndex,0).z)+hierarchyIndex;}int getBVHTriangle(const in sampler2D volume){return int(texelFetch(volume,bvhNodeIndex,0).y);}int getIntersections(const in sampler2D volume,const in int verticesIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0.0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r))points[count++]=vec4(r.z*a+r.x*b+r.y*c,1.0);current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}int getIntersections(const in sampler2D volume,const in int verticesIndex,const in int normalsIndex,const in int hierarchyIndex,const in int rootIndex,const in Line3 line,out vec4 points[ARRAY_SIZE],out vec3 normals[ARRAY_SIZE]){int current=getBVHRoot(volume,hierarchyIndex,rootIndex);int count=0;int stackIndex=-1;int stack[BVH_STACK_SIZE];while(stackIndex>=0||current>=0){if(current>=0){setBVHIndex(current);if(getBVHType(volume)==BVH_NODE){if(intersects(getBVHMin(volume),getBVHMax(volume),line)){stack[++stackIndex]=current;current=getBVHLeft(volume,hierarchyIndex);}else{current=-1;}}else{int t=getBVHTriangle(volume);int v=verticesIndex+t;vec3 r=vec3(0.0);vec3 a=texelFetch(volume,v,0).xyz;vec3 b=texelFetch(volume,v+1,0).xyz;vec3 c=texelFetch(volume,v+2,0).xyz;if(intersects(line,a,b,c,r)){points[count]=vec4(r.z*a+r.x*b+r.y*c,1.0);int n=normalsIndex+t;vec3 n0=texelFetch(volume,n,0).xyz;vec3 n1=texelFetch(volume,n+1,0).xyz;vec3 n2=texelFetch(volume,n+2,0).xyz;normals[count]=save_normalize(r.z*n0+r.x*n1+r.y*n2);++count;}current=-1;}}else{setBVHIndex(stack[stackIndex--]);current=getBVHRight(volume,hierarchyIndex);}}return count;}
|
|
186
|
+
`
|
|
629
187
|
;
|
|
630
188
|
|
|
631
189
|
Namespace_default().set ("x_ite/Browser/ParticleSystems/BVH.glsl", BVH_glsl_default_);
|
|
@@ -920,593 +478,18 @@ Object .assign (Object .setPrototypeOf (X3DParticleEmitterNode .prototype, (X3DN
|
|
|
920
478
|
gl = browser .getContext ();
|
|
921
479
|
|
|
922
480
|
const vertexShaderSource = /* glsl */ `#version 300 es
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
uniform float particleLifetime;
|
|
932
|
-
uniform float lifetimeVariation;
|
|
933
|
-
uniform float deltaTime;
|
|
934
|
-
uniform vec2 particleSize;
|
|
935
|
-
|
|
936
|
-
uniform int numForces;
|
|
937
|
-
uniform sampler2D forces;
|
|
938
|
-
|
|
939
|
-
uniform int boundedVerticesIndex;
|
|
940
|
-
uniform int boundedNormalsIndex;
|
|
941
|
-
uniform int boundedHierarchyIndex;
|
|
942
|
-
uniform int boundedHierarchyRoot;
|
|
943
|
-
uniform sampler2D boundedVolume;
|
|
944
|
-
|
|
945
|
-
uniform int numColors;
|
|
946
|
-
uniform sampler2D colorRamp;
|
|
947
|
-
|
|
948
|
-
uniform int texCoordCount;
|
|
949
|
-
uniform int numTexCoords;
|
|
950
|
-
uniform sampler2D texCoordRamp;
|
|
951
|
-
|
|
952
|
-
${Object .values (this .uniforms) .join ("\n")}
|
|
953
|
-
|
|
954
|
-
in vec4 input0; // (life, lifetime, elapsedTime, texCoordIndex0)
|
|
955
|
-
in vec4 input2; // (velocity, 0.0)
|
|
956
|
-
in vec4 input6; // position
|
|
957
|
-
|
|
958
|
-
out vec4 output0; // (life, lifetime, elapsedTime, texCoordIndex0)
|
|
959
|
-
out vec4 output1; // (color)
|
|
960
|
-
out vec4 output2; // (velocity, 0.0)
|
|
961
|
-
|
|
962
|
-
out vec4 output3; // scale rotation matrix
|
|
963
|
-
out vec4 output4; // scale rotation matrix
|
|
964
|
-
out vec4 output5; // scale rotation matrix
|
|
965
|
-
out vec4 output6; // position
|
|
966
|
-
|
|
967
|
-
// Constants
|
|
968
|
-
|
|
969
|
-
${Object .entries (ParticleSystems_GeometryTypes) .map (([k, v]) => `#define ${k} ${v}`) .join ("\n")}
|
|
970
|
-
|
|
971
|
-
const int ARRAY_SIZE = 32;
|
|
972
|
-
const float M_PI = 3.14159265359;
|
|
973
|
-
|
|
974
|
-
uniform float NaN;
|
|
975
|
-
|
|
976
|
-
// Texture
|
|
977
|
-
|
|
978
|
-
vec4
|
|
979
|
-
texelFetch (const in sampler2D sampler, const in int index, const in int lod)
|
|
980
|
-
{
|
|
981
|
-
int x = textureSize (sampler, lod) .x;
|
|
982
|
-
ivec2 p = ivec2 (index % x, index / x);
|
|
983
|
-
vec4 t = texelFetch (sampler, p, lod);
|
|
984
|
-
|
|
985
|
-
return t;
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
// Math
|
|
989
|
-
|
|
990
|
-
// Save normalize, that will not divide by zero.
|
|
991
|
-
vec3
|
|
992
|
-
save_normalize (const in vec3 vector)
|
|
993
|
-
{
|
|
994
|
-
float l = length (vector);
|
|
995
|
-
|
|
996
|
-
if (l == 0.0)
|
|
997
|
-
return vec3 (0.0);
|
|
998
|
-
|
|
999
|
-
return vector / l;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// Quaternion
|
|
1003
|
-
|
|
1004
|
-
vec4
|
|
1005
|
-
Quaternion (const in vec3 fromVector, const in vec3 toVector)
|
|
1006
|
-
{
|
|
1007
|
-
vec3 from = save_normalize (fromVector);
|
|
1008
|
-
vec3 to = save_normalize (toVector);
|
|
1009
|
-
|
|
1010
|
-
float cos_angle = dot (from, to);
|
|
1011
|
-
vec3 cross_vec = cross (from, to);
|
|
1012
|
-
float cross_len = length (cross_vec);
|
|
1013
|
-
|
|
1014
|
-
if (cross_len == 0.0)
|
|
1015
|
-
{
|
|
1016
|
-
if (cos_angle > 0.0)
|
|
1017
|
-
{
|
|
1018
|
-
return vec4 (0.0, 0.0, 0.0, 1.0);
|
|
1019
|
-
}
|
|
1020
|
-
else
|
|
1021
|
-
{
|
|
1022
|
-
vec3 t = cross (from, vec3 (1.0, 0.0, 0.0));
|
|
1023
|
-
|
|
1024
|
-
if (dot (t, t) == 0.0)
|
|
1025
|
-
t = cross (from, vec3 (0.0, 1.0, 0.0));
|
|
1026
|
-
|
|
1027
|
-
t = save_normalize (t);
|
|
1028
|
-
|
|
1029
|
-
return vec4 (t, 0.0);
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
else
|
|
1033
|
-
{
|
|
1034
|
-
float s = sqrt (abs (1.0 - cos_angle) * 0.5);
|
|
1035
|
-
|
|
1036
|
-
cross_vec = save_normalize (cross_vec);
|
|
1037
|
-
|
|
1038
|
-
return vec4 (cross_vec * s, sqrt (abs (1.0 + cos_angle) * 0.5));
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
vec3
|
|
1043
|
-
multVecQuat (const in vec3 v, const in vec4 q)
|
|
1044
|
-
{
|
|
1045
|
-
float a = q .w * q .w - q .x * q .x - q .y * q .y - q .z * q .z;
|
|
1046
|
-
float b = 2.0 * (v .x * q .x + v .y * q .y + v .z * q .z);
|
|
1047
|
-
float c = 2.0 * q .w;
|
|
1048
|
-
vec3 r = a * v .xyz + b * q .xyz + c * (q .yzx * v .zxy - q .zxy * v .yzx);
|
|
1049
|
-
|
|
1050
|
-
return r;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
mat3
|
|
1054
|
-
Matrix3 (const in vec4 quaternion)
|
|
1055
|
-
{
|
|
1056
|
-
float x = quaternion .x;
|
|
1057
|
-
float y = quaternion .y;
|
|
1058
|
-
float z = quaternion .z;
|
|
1059
|
-
float w = quaternion .w;
|
|
1060
|
-
float A = y * y;
|
|
1061
|
-
float B = z * z;
|
|
1062
|
-
float C = x * y;
|
|
1063
|
-
float D = z * w;
|
|
1064
|
-
float E = z * x;
|
|
1065
|
-
float F = y * w;
|
|
1066
|
-
float G = x * x;
|
|
1067
|
-
float H = y * z;
|
|
1068
|
-
float I = x * w;
|
|
1069
|
-
|
|
1070
|
-
return mat3 (1.0 - 2.0 * (A + B),
|
|
1071
|
-
2.0 * (C + D),
|
|
1072
|
-
2.0 * (E - F),
|
|
1073
|
-
2.0 * (C - D),
|
|
1074
|
-
1.0 - 2.0 * (B + G),
|
|
1075
|
-
2.0 * (H + I),
|
|
1076
|
-
2.0 * (E + F),
|
|
1077
|
-
2.0 * (H - I),
|
|
1078
|
-
1.0 - 2.0 * (A + G));
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
/* Random number generation */
|
|
1082
|
-
|
|
1083
|
-
uint seed = 1u;
|
|
1084
|
-
|
|
1085
|
-
void
|
|
1086
|
-
srand (const in int value)
|
|
1087
|
-
{
|
|
1088
|
-
seed = uint (value);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// Return a uniform distributed random floating point number in the interval [0, 1].
|
|
1092
|
-
float
|
|
1093
|
-
random ()
|
|
1094
|
-
{
|
|
1095
|
-
seed = seed * 1103515245u + 12345u;
|
|
1096
|
-
|
|
1097
|
-
return float (seed) / 4294967295.0;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
float
|
|
1101
|
-
getRandomValue (const in float min, const in float max)
|
|
1102
|
-
{
|
|
1103
|
-
return min + random () * (max - min);
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
float
|
|
1107
|
-
getRandomLifetime ()
|
|
1108
|
-
{
|
|
1109
|
-
float v = particleLifetime * lifetimeVariation;
|
|
1110
|
-
float min_ = max (0.0, particleLifetime - v);
|
|
1111
|
-
float max_ = particleLifetime + v;
|
|
1112
|
-
|
|
1113
|
-
return getRandomValue (min_, max_);
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
float
|
|
1117
|
-
getRandomSpeed ()
|
|
1118
|
-
{
|
|
1119
|
-
float v = speed * variation;
|
|
1120
|
-
float min_ = max (0.0, speed - v);
|
|
1121
|
-
float max_ = speed + v;
|
|
1122
|
-
|
|
1123
|
-
return getRandomValue (min_, max_);
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
vec3
|
|
1127
|
-
getRandomNormal ()
|
|
1128
|
-
{
|
|
1129
|
-
float theta = getRandomValue (-M_PI, M_PI);
|
|
1130
|
-
float cphi = getRandomValue (-1.0, 1.0);
|
|
1131
|
-
float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));
|
|
1132
|
-
|
|
1133
|
-
return vec3 (sin (theta) * r, cos (theta) * r, cphi);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
vec3
|
|
1137
|
-
getRandomNormalWithAngle (const in float angle)
|
|
1138
|
-
{
|
|
1139
|
-
float theta = getRandomValue (-M_PI, M_PI);
|
|
1140
|
-
float cphi = getRandomValue (cos (angle), 1.0);
|
|
1141
|
-
float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));
|
|
1142
|
-
|
|
1143
|
-
return vec3 (sin (theta) * r, cos (theta) * r, cphi);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
vec3
|
|
1147
|
-
getRandomNormalWithDirectionAndAngle (const in vec3 direction, const in float angle)
|
|
1148
|
-
{
|
|
1149
|
-
vec4 rotation = Quaternion (vec3 (0.0, 0.0, 1.0), direction);
|
|
1150
|
-
vec3 normal = getRandomNormalWithAngle (angle);
|
|
1151
|
-
|
|
1152
|
-
return multVecQuat (normal, rotation);
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
vec3
|
|
1156
|
-
getRandomSurfaceNormal (const in vec3 direction)
|
|
1157
|
-
{
|
|
1158
|
-
float theta = getRandomValue (-M_PI, M_PI);
|
|
1159
|
-
float cphi = pow (random (), 1.0 / 3.0);
|
|
1160
|
-
float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));
|
|
1161
|
-
vec3 normal = vec3 (sin (theta) * r, cos (theta) * r, cphi);
|
|
1162
|
-
vec4 rotation = Quaternion (vec3 (0.0, 0.0, 1.0), direction);
|
|
1163
|
-
|
|
1164
|
-
return multVecQuat (normal, rotation);
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
vec3
|
|
1168
|
-
getRandomSphericalVelocity ()
|
|
1169
|
-
{
|
|
1170
|
-
vec3 normal = getRandomNormal ();
|
|
1171
|
-
float speed = getRandomSpeed ();
|
|
1172
|
-
|
|
1173
|
-
return normal * speed;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
// Algorithms
|
|
1177
|
-
|
|
1178
|
-
int
|
|
1179
|
-
upperBound (const in sampler2D sampler, in int count, const in float value)
|
|
1180
|
-
{
|
|
1181
|
-
int first = 0;
|
|
1182
|
-
int step = 0;
|
|
1183
|
-
|
|
1184
|
-
while (count > 0)
|
|
1185
|
-
{
|
|
1186
|
-
int index = first;
|
|
1187
|
-
|
|
1188
|
-
step = count >> 1;
|
|
1189
|
-
|
|
1190
|
-
index += step;
|
|
1191
|
-
|
|
1192
|
-
if (value < texelFetch (sampler, index, 0) .x)
|
|
1193
|
-
{
|
|
1194
|
-
count = step;
|
|
1195
|
-
}
|
|
1196
|
-
else
|
|
1197
|
-
{
|
|
1198
|
-
first = ++ index;
|
|
1199
|
-
count -= step + 1;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
return first;
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
void
|
|
1207
|
-
interpolate (const in sampler2D sampler, const in int count, const in float fraction, out int index0, out int index1, out float weight)
|
|
1208
|
-
{
|
|
1209
|
-
// Determine index0, index1 and weight.
|
|
1210
|
-
|
|
1211
|
-
if (count == 1 || fraction <= texelFetch (sampler, 0, 0) .x)
|
|
1212
|
-
{
|
|
1213
|
-
index0 = 0;
|
|
1214
|
-
index1 = 0;
|
|
1215
|
-
weight = 0.0;
|
|
1216
|
-
}
|
|
1217
|
-
else if (fraction >= texelFetch (sampler, count - 1, 0) .x)
|
|
1218
|
-
{
|
|
1219
|
-
index0 = count - 2;
|
|
1220
|
-
index1 = count - 1;
|
|
1221
|
-
weight = 1.0;
|
|
1222
|
-
}
|
|
1223
|
-
else
|
|
1224
|
-
{
|
|
1225
|
-
int index = upperBound (sampler, count, fraction);
|
|
1226
|
-
|
|
1227
|
-
if (index < count)
|
|
1228
|
-
{
|
|
1229
|
-
index1 = index;
|
|
1230
|
-
index0 = index - 1;
|
|
1231
|
-
|
|
1232
|
-
float key0 = texelFetch (sampler, index0, 0) .x;
|
|
1233
|
-
float key1 = texelFetch (sampler, index1, 0) .x;
|
|
1234
|
-
|
|
1235
|
-
weight = clamp ((fraction - key0) / (key1 - key0), 0.0, 1.0);
|
|
1236
|
-
}
|
|
1237
|
-
else
|
|
1238
|
-
{
|
|
1239
|
-
index0 = 0;
|
|
1240
|
-
index1 = 0;
|
|
1241
|
-
weight = 0.0;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
void
|
|
1247
|
-
interpolate (const in sampler2D sampler, const in int count, const in float fraction, out int index0)
|
|
1248
|
-
{
|
|
1249
|
-
// Determine index0.
|
|
1250
|
-
|
|
1251
|
-
if (count == 1 || fraction <= texelFetch (sampler, 0, 0) .x)
|
|
1252
|
-
{
|
|
1253
|
-
index0 = 0;
|
|
1254
|
-
}
|
|
1255
|
-
else if (fraction >= texelFetch (sampler, count - 1, 0) .x)
|
|
1256
|
-
{
|
|
1257
|
-
index0 = count - 2;
|
|
1258
|
-
}
|
|
1259
|
-
else
|
|
1260
|
-
{
|
|
1261
|
-
int index = upperBound (sampler, count, fraction);
|
|
1262
|
-
|
|
1263
|
-
if (index < count)
|
|
1264
|
-
index0 = index - 1;
|
|
1265
|
-
else
|
|
1266
|
-
index0 = 0;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
vec3
|
|
1271
|
-
getRandomBarycentricCoord ()
|
|
1272
|
-
{
|
|
1273
|
-
// Random barycentric coordinates.
|
|
1274
|
-
|
|
1275
|
-
float u = random ();
|
|
1276
|
-
float v = random ();
|
|
1277
|
-
|
|
1278
|
-
if (u + v > 1.0)
|
|
1279
|
-
{
|
|
1280
|
-
u = 1.0 - u;
|
|
1281
|
-
v = 1.0 - v;
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
float t = 1.0 - u - v;
|
|
1285
|
-
|
|
1286
|
-
return vec3 (t, u, v);
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
void
|
|
1290
|
-
getRandomPointOnSurface (const in sampler2D surface, const in int verticesIndex, const in int normalsIndex, out vec4 position, out vec3 normal)
|
|
1291
|
-
{
|
|
1292
|
-
// Determine index0, index1 and weight.
|
|
1293
|
-
|
|
1294
|
-
float lastAreaSoFar = texelFetch (surface, verticesIndex - 1, 0) .x;
|
|
1295
|
-
float fraction = random () * lastAreaSoFar;
|
|
1296
|
-
|
|
1297
|
-
int index0;
|
|
1298
|
-
int index1;
|
|
1299
|
-
int index2;
|
|
1300
|
-
float weight;
|
|
1301
|
-
|
|
1302
|
-
interpolate (surface, verticesIndex, fraction, index0, index1, weight);
|
|
1303
|
-
|
|
1304
|
-
// Interpolate and return position.
|
|
1305
|
-
|
|
1306
|
-
index0 *= 3;
|
|
1307
|
-
index1 = index0 + 1;
|
|
1308
|
-
index2 = index0 + 2;
|
|
1309
|
-
|
|
1310
|
-
vec4 vertex0 = texelFetch (surface, verticesIndex + index0, 0);
|
|
1311
|
-
vec4 vertex1 = texelFetch (surface, verticesIndex + index1, 0);
|
|
1312
|
-
vec4 vertex2 = texelFetch (surface, verticesIndex + index2, 0);
|
|
1313
|
-
|
|
1314
|
-
vec3 normal0 = texelFetch (surface, normalsIndex + index0, 0) .xyz;
|
|
1315
|
-
vec3 normal1 = texelFetch (surface, normalsIndex + index1, 0) .xyz;
|
|
1316
|
-
vec3 normal2 = texelFetch (surface, normalsIndex + index2, 0) .xyz;
|
|
1317
|
-
|
|
1318
|
-
// Random barycentric coordinates.
|
|
1319
|
-
|
|
1320
|
-
vec3 r = getRandomBarycentricCoord ();
|
|
1321
|
-
|
|
1322
|
-
// Calculate position and direction.
|
|
1323
|
-
|
|
1324
|
-
position = r .z * vertex0 + r .x * vertex1 + r .y * vertex2;
|
|
1325
|
-
normal = save_normalize (r .z * normal0 + r .x * normal1 + r .y * normal2);
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
// Functions
|
|
1329
|
-
|
|
1330
|
-
${this .functions .join ("\n")}
|
|
1331
|
-
|
|
1332
|
-
// Current values
|
|
1333
|
-
|
|
1334
|
-
vec4
|
|
1335
|
-
getColor (const in float lifetime, const in float elapsedTime)
|
|
1336
|
-
{
|
|
1337
|
-
if (numColors > 0)
|
|
1338
|
-
{
|
|
1339
|
-
// Determine index0, index1 and weight.
|
|
1340
|
-
|
|
1341
|
-
float fraction = elapsedTime / lifetime;
|
|
1342
|
-
|
|
1343
|
-
int index0;
|
|
1344
|
-
int index1;
|
|
1345
|
-
float weight;
|
|
1346
|
-
|
|
1347
|
-
interpolate (colorRamp, numColors, fraction, index0, index1, weight);
|
|
1348
|
-
|
|
1349
|
-
// Interpolate and return color.
|
|
1350
|
-
|
|
1351
|
-
vec4 color0 = texelFetch (colorRamp, numColors + index0, 0);
|
|
1352
|
-
vec4 color1 = texelFetch (colorRamp, numColors + index1, 0);
|
|
1353
|
-
|
|
1354
|
-
return mix (color0, color1, weight);
|
|
1355
|
-
}
|
|
1356
|
-
else
|
|
1357
|
-
{
|
|
1358
|
-
return vec4 (1.0);
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
void
|
|
1363
|
-
bounce (const in vec4 fromPosition, inout vec4 toPosition, inout vec3 velocity)
|
|
1364
|
-
{
|
|
1365
|
-
if (boundedHierarchyRoot < 0)
|
|
1366
|
-
return;
|
|
1367
|
-
|
|
1368
|
-
Line3 line = Line3 (fromPosition .xyz, save_normalize (velocity));
|
|
1369
|
-
|
|
1370
|
-
vec4 points [ARRAY_SIZE];
|
|
1371
|
-
vec3 normals [ARRAY_SIZE];
|
|
1372
|
-
|
|
1373
|
-
int numIntersections = getIntersections (boundedVolume, boundedVerticesIndex, boundedNormalsIndex, boundedHierarchyIndex, boundedHierarchyRoot, line, points, normals);
|
|
1374
|
-
|
|
1375
|
-
if (numIntersections == 0)
|
|
1376
|
-
return;
|
|
1377
|
-
|
|
1378
|
-
Plane3 plane1 = plane3 (line .point, line .direction);
|
|
1379
|
-
|
|
1380
|
-
int index = min_index (points, numIntersections, 0.0, plane1);
|
|
1381
|
-
|
|
1382
|
-
if (index == -1)
|
|
1383
|
-
return;
|
|
1384
|
-
|
|
1385
|
-
Plane3 plane2 = plane3 (points [index] .xyz, normals [index]);
|
|
1386
|
-
|
|
1387
|
-
if (sign (plane_distance (plane2, fromPosition .xyz)) == sign (plane_distance (plane2, toPosition .xyz)))
|
|
1388
|
-
return;
|
|
1389
|
-
|
|
1390
|
-
velocity = reflect (velocity, normals [index]);
|
|
1391
|
-
toPosition = vec4 (points [index] .xyz + reflect (points [index] .xyz - fromPosition .xyz, normals [index]), 1.0);
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
int
|
|
1395
|
-
getTexCoordIndex0 (const in float lifetime, const in float elapsedTime)
|
|
1396
|
-
{
|
|
1397
|
-
if (numTexCoords == 0)
|
|
1398
|
-
{
|
|
1399
|
-
return -1;
|
|
1400
|
-
}
|
|
1401
|
-
else
|
|
1402
|
-
{
|
|
1403
|
-
float fraction = elapsedTime / lifetime;
|
|
1404
|
-
int index0 = 0;
|
|
1405
|
-
|
|
1406
|
-
interpolate (texCoordRamp, numTexCoords, fraction, index0);
|
|
1407
|
-
|
|
1408
|
-
return numTexCoords + index0 * texCoordCount;
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
void
|
|
1413
|
-
main ()
|
|
1414
|
-
{
|
|
1415
|
-
int life = int (input0 [0]);
|
|
1416
|
-
float lifetime = input0 [1];
|
|
1417
|
-
float elapsedTime = input0 [2] + deltaTime;
|
|
1418
|
-
|
|
1419
|
-
srand ((gl_VertexID + randomSeed) * randomSeed);
|
|
1420
|
-
|
|
1421
|
-
if (elapsedTime > lifetime)
|
|
1422
|
-
{
|
|
1423
|
-
// Create new particle or hide particle.
|
|
1424
|
-
|
|
1425
|
-
lifetime = getRandomLifetime ();
|
|
1426
|
-
elapsedTime = 0.0;
|
|
1427
|
-
|
|
1428
|
-
output0 = vec4 (max (life + 1, 1), lifetime, elapsedTime, getTexCoordIndex0 (lifetime, elapsedTime));
|
|
1429
|
-
|
|
1430
|
-
if (createParticles)
|
|
1431
|
-
{
|
|
1432
|
-
output1 = getColor (lifetime, elapsedTime);
|
|
1433
|
-
output2 = vec4 (getRandomVelocity (), 0.0);
|
|
1434
|
-
output6 = getRandomPosition ();
|
|
1435
|
-
}
|
|
1436
|
-
else
|
|
1437
|
-
{
|
|
1438
|
-
output1 = vec4 (0.0);
|
|
1439
|
-
output2 = vec4 (0.0);
|
|
1440
|
-
output6 = vec4 (NaN);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
else
|
|
1444
|
-
{
|
|
1445
|
-
// Animate particle.
|
|
1446
|
-
|
|
1447
|
-
vec3 velocity = input2 .xyz;
|
|
1448
|
-
vec4 position = input6;
|
|
1449
|
-
|
|
1450
|
-
for (int i = 0; i < numForces; ++ i)
|
|
1451
|
-
{
|
|
1452
|
-
vec4 force = texelFetch (forces, i, 0);
|
|
1453
|
-
float turbulence = force .w;
|
|
1454
|
-
vec3 normal = getRandomNormalWithDirectionAndAngle (force .xyz, turbulence);
|
|
1455
|
-
float speed = length (force .xyz);
|
|
1456
|
-
|
|
1457
|
-
velocity += normal * speed;
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
position .xyz += velocity * deltaTime;
|
|
1461
|
-
|
|
1462
|
-
bounce (input6, position, velocity);
|
|
1463
|
-
|
|
1464
|
-
output0 = vec4 (life, lifetime, elapsedTime, getTexCoordIndex0 (lifetime, elapsedTime));
|
|
1465
|
-
output1 = getColor (lifetime, elapsedTime);
|
|
1466
|
-
output2 = vec4 (velocity, 0.0);
|
|
1467
|
-
output6 = position;
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
switch (geometryType)
|
|
1471
|
-
{
|
|
1472
|
-
case POINT:
|
|
1473
|
-
case SPRITE:
|
|
1474
|
-
case GEOMETRY:
|
|
1475
|
-
{
|
|
1476
|
-
output3 = vec4 (1.0, 0.0, 0.0, 0.0);
|
|
1477
|
-
output4 = vec4 (0.0, 1.0, 0.0, 0.0);
|
|
1478
|
-
output5 = vec4 (0.0, 0.0, 1.0, 0.0);
|
|
1479
|
-
break;
|
|
1480
|
-
}
|
|
1481
|
-
case LINE:
|
|
1482
|
-
{
|
|
1483
|
-
mat3 r = Matrix3 (Quaternion (vec3 (0.0, 0.0, 1.0), output2 .xyz));
|
|
1484
|
-
mat3 s = mat3 (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, particleSize .y);
|
|
1485
|
-
mat3 m = r * s;
|
|
1486
|
-
|
|
1487
|
-
output3 = vec4 (m [0], 0.0);
|
|
1488
|
-
output4 = vec4 (m [1], 0.0);
|
|
1489
|
-
output5 = vec4 (m [2], 0.0);
|
|
1490
|
-
break;
|
|
1491
|
-
}
|
|
1492
|
-
default: // QUAD, TRIANGLE
|
|
1493
|
-
{
|
|
1494
|
-
output3 = vec4 (particleSize .x, 0.0, 0.0, 0.0);
|
|
1495
|
-
output4 = vec4 (0.0, particleSize .y, 0.0, 0.0);
|
|
1496
|
-
output5 = vec4 (0.0, 0.0, 1.0, 0.0);
|
|
1497
|
-
break;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
`;
|
|
481
|
+
precision highp float;precision highp int;precision highp sampler2D;uniform int randomSeed;uniform int geometryType;uniform bool createParticles;uniform float particleLifetime;uniform float lifetimeVariation;uniform float deltaTime;uniform vec2 particleSize;uniform int numForces;uniform sampler2D forces;uniform int boundedVerticesIndex;uniform int boundedNormalsIndex;uniform int boundedHierarchyIndex;uniform int boundedHierarchyRoot;uniform sampler2D boundedVolume;uniform int numColors;uniform sampler2D colorRamp;uniform int texCoordCount;uniform int numTexCoords;uniform sampler2D texCoordRamp;
|
|
482
|
+
${Object .values (this .uniforms) .join ("\n")}
|
|
483
|
+
in vec4 input0;in vec4 input2;in vec4 input6;out vec4 output0;out vec4 output1;out vec4 output2;out vec4 output3;out vec4 output4;out vec4 output5;out vec4 output6;
|
|
484
|
+
${Object .entries (ParticleSystems_GeometryTypes) .map (([k, v]) => `#define ${k} ${v}`) .join ("\n")}
|
|
485
|
+
const int ARRAY_SIZE=32;const float M_PI=3.14159265359;uniform float NaN;vec4 texelFetch(const in sampler2D sampler,const in int index,const in int lod){int x=textureSize(sampler,lod).x;ivec2 p=ivec2(index % x,index/x);vec4 t=texelFetch(sampler,p,lod);return t;}vec3 save_normalize(const in vec3 vector){float l=length(vector);if(l==0.0)return vec3(0.0);return vector/l;}vec4 Quaternion(const in vec3 fromVector,const in vec3 toVector){vec3 from=save_normalize(fromVector);vec3 to=save_normalize(toVector);float cos_angle=dot(from,to);vec3 cross_vec=cross(from,to);float cross_len=length(cross_vec);if(cross_len==0.0){if(cos_angle>0.0){return vec4(0.0,0.0,0.0,1.0);}else{vec3 t=cross(from,vec3(1.0,0.0,0.0));if(dot(t,t)==0.0)t=cross(from,vec3(0.0,1.0,0.0));t=save_normalize(t);return vec4(t,0.0);}}else{float s=sqrt(abs(1.0-cos_angle)*0.5);cross_vec=save_normalize(cross_vec);return vec4(cross_vec*s,sqrt(abs(1.0+cos_angle)*0.5));}}vec3 multVecQuat(const in vec3 v,const in vec4 q){float a=q.w*q.w-q.x*q.x-q.y*q.y-q.z*q.z;float b=2.0*(v.x*q.x+v.y*q.y+v.z*q.z);float c=2.0*q.w;vec3 r=a*v.xyz+b*q.xyz+c*(q.yzx*v.zxy-q.zxy*v.yzx);return r;}mat3 Matrix3(const in vec4 quaternion){float x=quaternion.x;float y=quaternion.y;float z=quaternion.z;float w=quaternion.w;float A=y*y;float B=z*z;float C=x*y;float D=z*w;float E=z*x;float F=y*w;float G=x*x;float H=y*z;float I=x*w;return mat3(1.0-2.0*(A+B),2.0*(C+D),2.0*(E-F),2.0*(C-D),1.0-2.0*(B+G),2.0*(H+I),2.0*(E+F),2.0*(H-I),1.0-2.0*(A+G));}uint seed=1u;void srand(const in int value){seed=uint(value);}float random(){seed=seed*1103515245u+12345u;return float(seed)/4294967295.0;}float getRandomValue(const in float min,const in float max){return min+random()*(max-min);}float getRandomLifetime(){float v=particleLifetime*lifetimeVariation;float min_=max(0.0,particleLifetime-v);float max_=particleLifetime+v;return getRandomValue(min_,max_);}float getRandomSpeed(){float v=speed*variation;float min_=max(0.0,speed-v);float max_=speed+v;return getRandomValue(min_,max_);}vec3 getRandomNormal(){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(-1.0,1.0);float r=sqrt(1.0-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithAngle(const in float angle){float theta=getRandomValue(-M_PI,M_PI);float cphi=getRandomValue(cos(angle),1.0);float r=sqrt(1.0-cphi*cphi);return vec3(sin(theta)*r,cos(theta)*r,cphi);}vec3 getRandomNormalWithDirectionAndAngle(const in vec3 direction,const in float angle){vec4 rotation=Quaternion(vec3(0.0,0.0,1.0),direction);vec3 normal=getRandomNormalWithAngle(angle);return multVecQuat(normal,rotation);}vec3 getRandomSurfaceNormal(const in vec3 direction){float theta=getRandomValue(-M_PI,M_PI);float cphi=pow(random(),1.0/3.0);float r=sqrt(1.0-cphi*cphi);vec3 normal=vec3(sin(theta)*r,cos(theta)*r,cphi);vec4 rotation=Quaternion(vec3(0.0,0.0,1.0),direction);return multVecQuat(normal,rotation);}vec3 getRandomSphericalVelocity(){vec3 normal=getRandomNormal();float speed=getRandomSpeed();return normal*speed;}int upperBound(const in sampler2D sampler,in int count,const in float value){int first=0;int step=0;while(count>0){int index=first;step=count>>1;index+=step;if(value<texelFetch(sampler,index,0).x){count=step;}else{first=++index;count-=step+1;}}return first;}void interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0,out int index1,out float weight){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;index1=0;weight=0.0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;index1=count-1;weight=1.0;}else{int index=upperBound(sampler,count,fraction);if(index<count){index1=index;index0=index-1;float key0=texelFetch(sampler,index0,0).x;float key1=texelFetch(sampler,index1,0).x;weight=clamp((fraction-key0)/(key1-key0),0.0,1.0);}else{index0=0;index1=0;weight=0.0;}}}void interpolate(const in sampler2D sampler,const in int count,const in float fraction,out int index0){if(count==1||fraction<=texelFetch(sampler,0,0).x){index0=0;}else if(fraction>=texelFetch(sampler,count-1,0).x){index0=count-2;}else{int index=upperBound(sampler,count,fraction);if(index<count)index0=index-1;else index0=0;}}vec3 getRandomBarycentricCoord(){float u=random();float v=random();if(u+v>1.0){u=1.0-u;v=1.0-v;}float t=1.0-u-v;return vec3(t,u,v);}void getRandomPointOnSurface(const in sampler2D surface,const in int verticesIndex,const in int normalsIndex,out vec4 position,out vec3 normal){float lastAreaSoFar=texelFetch(surface,verticesIndex-1,0).x;float fraction=random()*lastAreaSoFar;int index0;int index1;int index2;float weight;interpolate(surface,verticesIndex,fraction,index0,index1,weight);index0*=3;index1=index0+1;index2=index0+2;vec4 vertex0=texelFetch(surface,verticesIndex+index0,0);vec4 vertex1=texelFetch(surface,verticesIndex+index1,0);vec4 vertex2=texelFetch(surface,verticesIndex+index2,0);vec3 normal0=texelFetch(surface,normalsIndex+index0,0).xyz;vec3 normal1=texelFetch(surface,normalsIndex+index1,0).xyz;vec3 normal2=texelFetch(surface,normalsIndex+index2,0).xyz;vec3 r=getRandomBarycentricCoord();position=r.z*vertex0+r.x*vertex1+r.y*vertex2;normal=save_normalize(r.z*normal0+r.x*normal1+r.y*normal2);}
|
|
486
|
+
${this .functions .join ("\n")}
|
|
487
|
+
vec4 getColor(const in float lifetime,const in float elapsedTime){if(numColors>0){float fraction=elapsedTime/lifetime;int index0;int index1;float weight;interpolate(colorRamp,numColors,fraction,index0,index1,weight);vec4 color0=texelFetch(colorRamp,numColors+index0,0);vec4 color1=texelFetch(colorRamp,numColors+index1,0);return mix(color0,color1,weight);}else{return vec4(1.0);}}void bounce(const in vec4 fromPosition,inout vec4 toPosition,inout vec3 velocity){if(boundedHierarchyRoot<0)return;Line3 line=Line3(fromPosition.xyz,save_normalize(velocity));vec4 points[ARRAY_SIZE];vec3 normals[ARRAY_SIZE];int numIntersections=getIntersections(boundedVolume,boundedVerticesIndex,boundedNormalsIndex,boundedHierarchyIndex,boundedHierarchyRoot,line,points,normals);if(numIntersections==0)return;Plane3 plane1=plane3(line.point,line.direction);int index=min_index(points,numIntersections,0.0,plane1);if(index==-1)return;Plane3 plane2=plane3(points[index].xyz,normals[index]);if(sign(plane_distance(plane2,fromPosition.xyz))==sign(plane_distance(plane2,toPosition.xyz)))return;velocity=reflect(velocity,normals[index]);toPosition=vec4(points[index].xyz+reflect(points[index].xyz-fromPosition.xyz,normals[index]),1.0);}int getTexCoordIndex0(const in float lifetime,const in float elapsedTime){if(numTexCoords==0){return-1;}else{float fraction=elapsedTime/lifetime;int index0=0;interpolate(texCoordRamp,numTexCoords,fraction,index0);return numTexCoords+index0*texCoordCount;}}void main(){int life=int(input0[0]);float lifetime=input0[1];float elapsedTime=input0[2]+deltaTime;srand((gl_VertexID+randomSeed)*randomSeed);if(elapsedTime>lifetime){lifetime=getRandomLifetime();elapsedTime=0.0;output0=vec4(max(life+1,1),lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));if(createParticles){output1=getColor(lifetime,elapsedTime);output2=vec4(getRandomVelocity(),0.0);output6=getRandomPosition();}else{output1=vec4(0.0);output2=vec4(0.0);output6=vec4(NaN);}}else{vec3 velocity=input2.xyz;vec4 position=input6;for(int i=0;i<numForces;++i){vec4 force=texelFetch(forces,i,0);float turbulence=force.w;vec3 normal=getRandomNormalWithDirectionAndAngle(force.xyz,turbulence);float speed=length(force.xyz);velocity+=normal*speed;}position.xyz+=velocity*deltaTime;bounce(input6,position,velocity);output0=vec4(life,lifetime,elapsedTime,getTexCoordIndex0(lifetime,elapsedTime));output1=getColor(lifetime,elapsedTime);output2=vec4(velocity,0.0);output6=position;}switch(geometryType){case POINT:case SPRITE:case GEOMETRY:{output3=vec4(1.0,0.0,0.0,0.0);output4=vec4(0.0,1.0,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}case LINE:{mat3 r=Matrix3(Quaternion(vec3(0.0,0.0,1.0),output2.xyz));mat3 s=mat3(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,particleSize.y);mat3 m=r*s;output3=vec4(m[0],0.0);output4=vec4(m[1],0.0);output5=vec4(m[2],0.0);break;}default:{output3=vec4(particleSize.x,0.0,0.0,0.0);output4=vec4(0.0,particleSize.y,0.0,0.0);output5=vec4(0.0,0.0,1.0,0.0);break;}}}
|
|
488
|
+
`
|
|
1502
489
|
|
|
1503
490
|
const fragmentShaderSource = /* glsl */ `#version 300 es
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
void
|
|
1508
|
-
main () { }
|
|
1509
|
-
`;
|
|
491
|
+
precision highp float;void main(){}
|
|
492
|
+
`
|
|
1510
493
|
|
|
1511
494
|
// Vertex shader
|
|
1512
495
|
|
|
@@ -1515,6 +498,9 @@ Object .assign (Object .setPrototypeOf (X3DParticleEmitterNode .prototype, (X3DN
|
|
|
1515
498
|
gl .shaderSource (vertexShader, vertexShaderSource);
|
|
1516
499
|
gl .compileShader (vertexShader);
|
|
1517
500
|
|
|
501
|
+
if (!gl .getShaderParameter (vertexShader, gl .COMPILE_STATUS))
|
|
502
|
+
console .error (gl .getShaderInfoLog (vertexShader));
|
|
503
|
+
|
|
1518
504
|
// Fragment shader
|
|
1519
505
|
|
|
1520
506
|
const fragmentShader = gl .createShader (gl .FRAGMENT_SHADER);
|
|
@@ -1522,6 +508,9 @@ Object .assign (Object .setPrototypeOf (X3DParticleEmitterNode .prototype, (X3DN
|
|
|
1522
508
|
gl .shaderSource (fragmentShader, fragmentShaderSource);
|
|
1523
509
|
gl .compileShader (fragmentShader);
|
|
1524
510
|
|
|
511
|
+
if (!gl .getShaderParameter (fragmentShader, gl .COMPILE_STATUS))
|
|
512
|
+
console .error (gl .getShaderInfoLog (fragmentShader));
|
|
513
|
+
|
|
1525
514
|
// Program
|
|
1526
515
|
|
|
1527
516
|
const program = gl .createProgram ();
|
|
@@ -1634,7 +623,7 @@ const X3DParticleEmitterNode_default_ = X3DParticleEmitterNode;
|
|
|
1634
623
|
Namespace_default().set ("x_ite/Components/ParticleSystems/X3DParticleEmitterNode", X3DParticleEmitterNode_default_);
|
|
1635
624
|
/* harmony default export */ const ParticleSystems_X3DParticleEmitterNode = (X3DParticleEmitterNode_default_);
|
|
1636
625
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Vector3\")"
|
|
1637
|
-
const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
626
|
+
const Vector3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Numbers/Vector3");
|
|
1638
627
|
var Vector3_default = /*#__PURE__*/__webpack_require__.n(Vector3_namespaceObject);
|
|
1639
628
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/PointEmitter.js
|
|
1640
629
|
/*******************************************************************************
|
|
@@ -1955,7 +944,7 @@ const X3DParticlePhysicsModelNode_default_ = X3DParticlePhysicsModelNode;
|
|
|
1955
944
|
Namespace_default().set ("x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode", X3DParticlePhysicsModelNode_default_);
|
|
1956
945
|
/* harmony default export */ const ParticleSystems_X3DParticlePhysicsModelNode = (X3DParticlePhysicsModelNode_default_);
|
|
1957
946
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Base/X3DCast\")"
|
|
1958
|
-
const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
947
|
+
const X3DCast_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Base/X3DCast");
|
|
1959
948
|
var X3DCast_default = /*#__PURE__*/__webpack_require__.n(X3DCast_namespaceObject);
|
|
1960
949
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js
|
|
1961
950
|
/*******************************************************************************
|
|
@@ -2529,28 +1518,28 @@ const ForcePhysicsModel_default_ = ForcePhysicsModel;
|
|
|
2529
1518
|
Namespace_default().set ("x_ite/Components/ParticleSystems/ForcePhysicsModel", ForcePhysicsModel_default_);
|
|
2530
1519
|
/* harmony default export */ const ParticleSystems_ForcePhysicsModel = (ForcePhysicsModel_default_);
|
|
2531
1520
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Shape/X3DShapeNode\")"
|
|
2532
|
-
const X3DShapeNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1521
|
+
const X3DShapeNode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Components/Shape/X3DShapeNode");
|
|
2533
1522
|
var X3DShapeNode_default = /*#__PURE__*/__webpack_require__.n(X3DShapeNode_namespaceObject);
|
|
2534
1523
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Browser/Rendering/GeometryContext\")"
|
|
2535
|
-
const GeometryContext_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1524
|
+
const GeometryContext_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Browser/Rendering/GeometryContext");
|
|
2536
1525
|
var GeometryContext_default = /*#__PURE__*/__webpack_require__.n(GeometryContext_namespaceObject);
|
|
2537
1526
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Rendering/VertexArray\")"
|
|
2538
|
-
const VertexArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1527
|
+
const VertexArray_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Rendering/VertexArray");
|
|
2539
1528
|
var VertexArray_default = /*#__PURE__*/__webpack_require__.n(VertexArray_namespaceObject);
|
|
2540
1529
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Rendering/TraverseType\")"
|
|
2541
|
-
const TraverseType_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1530
|
+
const TraverseType_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Rendering/TraverseType");
|
|
2542
1531
|
var TraverseType_default = /*#__PURE__*/__webpack_require__.n(TraverseType_namespaceObject);
|
|
2543
1532
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Browser/Shape/AlphaMode\")"
|
|
2544
|
-
const AlphaMode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1533
|
+
const AlphaMode_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Browser/Shape/AlphaMode");
|
|
2545
1534
|
var AlphaMode_default = /*#__PURE__*/__webpack_require__.n(AlphaMode_namespaceObject);
|
|
2546
1535
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Matrix4\")"
|
|
2547
|
-
const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1536
|
+
const Matrix4_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Numbers/Matrix4");
|
|
2548
1537
|
var Matrix4_default = /*#__PURE__*/__webpack_require__.n(Matrix4_namespaceObject);
|
|
2549
1538
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Numbers/Matrix3\")"
|
|
2550
|
-
const Matrix3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1539
|
+
const Matrix3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Numbers/Matrix3");
|
|
2551
1540
|
var Matrix3_default = /*#__PURE__*/__webpack_require__.n(Matrix3_namespaceObject);
|
|
2552
1541
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Geometry/Plane3\")"
|
|
2553
|
-
const Plane3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
1542
|
+
const Plane3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Geometry/Plane3");
|
|
2554
1543
|
var Plane3_default = /*#__PURE__*/__webpack_require__.n(Plane3_namespaceObject);
|
|
2555
1544
|
;// CONCATENATED MODULE: ./src/standard/Math/Algorithms/QuickSort.js
|
|
2556
1545
|
/*******************************************************************************
|
|
@@ -4134,7 +3123,7 @@ const ParticleSystem_default_ = ParticleSystem;
|
|
|
4134
3123
|
Namespace_default().set ("x_ite/Components/ParticleSystems/ParticleSystem", ParticleSystem_default_);
|
|
4135
3124
|
/* harmony default export */ const ParticleSystems_ParticleSystem = (ParticleSystem_default_);
|
|
4136
3125
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Rendering/IndexedLineSet\")"
|
|
4137
|
-
const IndexedLineSet_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
3126
|
+
const IndexedLineSet_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Components/Rendering/IndexedLineSet");
|
|
4138
3127
|
var IndexedLineSet_default = /*#__PURE__*/__webpack_require__.n(IndexedLineSet_namespaceObject);
|
|
4139
3128
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/PolylineEmitter.js
|
|
4140
3129
|
/*******************************************************************************
|
|
@@ -4386,7 +3375,7 @@ const PolylineEmitter_default_ = PolylineEmitter;
|
|
|
4386
3375
|
Namespace_default().set ("x_ite/Components/ParticleSystems/PolylineEmitter", PolylineEmitter_default_);
|
|
4387
3376
|
/* harmony default export */ const ParticleSystems_PolylineEmitter = (PolylineEmitter_default_);
|
|
4388
3377
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Geometry/Triangle3\")"
|
|
4389
|
-
const Triangle3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
3378
|
+
const Triangle3_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Geometry/Triangle3");
|
|
4390
3379
|
var Triangle3_default = /*#__PURE__*/__webpack_require__.n(Triangle3_namespaceObject);
|
|
4391
3380
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/SurfaceEmitter.js
|
|
4392
3381
|
/*******************************************************************************
|
|
@@ -4646,7 +3635,7 @@ const SurfaceEmitter_default_ = SurfaceEmitter;
|
|
|
4646
3635
|
Namespace_default().set ("x_ite/Components/ParticleSystems/SurfaceEmitter", SurfaceEmitter_default_);
|
|
4647
3636
|
/* harmony default export */ const ParticleSystems_SurfaceEmitter = (SurfaceEmitter_default_);
|
|
4648
3637
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"x_ite/Components/Geometry3D/IndexedFaceSet\")"
|
|
4649
|
-
const IndexedFaceSet_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
3638
|
+
const IndexedFaceSet_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("x_ite/Components/Geometry3D/IndexedFaceSet");
|
|
4650
3639
|
var IndexedFaceSet_default = /*#__PURE__*/__webpack_require__.n(IndexedFaceSet_namespaceObject);
|
|
4651
3640
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/VolumeEmitter.js
|
|
4652
3641
|
/*******************************************************************************
|
|
@@ -4943,7 +3932,7 @@ const VolumeEmitter_default_ = VolumeEmitter;
|
|
|
4943
3932
|
Namespace_default().set ("x_ite/Components/ParticleSystems/VolumeEmitter", VolumeEmitter_default_);
|
|
4944
3933
|
/* harmony default export */ const ParticleSystems_VolumeEmitter = (VolumeEmitter_default_);
|
|
4945
3934
|
;// CONCATENATED MODULE: external "window [Symbol .for (\"X_ITE.X3D\")] .require (\"standard/Math/Algorithm\")"
|
|
4946
|
-
const Algorithm_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.
|
|
3935
|
+
const Algorithm_namespaceObject = window [Symbol .for ("X_ITE.X3D-8.11.6")] .require ("standard/Math/Algorithm");
|
|
4947
3936
|
var Algorithm_default = /*#__PURE__*/__webpack_require__.n(Algorithm_namespaceObject);
|
|
4948
3937
|
;// CONCATENATED MODULE: ./src/x_ite/Components/ParticleSystems/WindPhysicsModel.js
|
|
4949
3938
|
/*******************************************************************************
|