@woosh/meep-engine 2.33.36 → 2.33.37
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/core/collection/HashMap.js +19 -12
- package/core/collection/table/RowFirstTable.js +13 -8
- package/core/collection/table/RowFirstTableSpec.js +6 -0
- package/core/color/Color.js +5 -9
- package/core/color/ColorUtils.js +4 -150
- package/core/color/YCbCr_to_rgb_uint24.js +20 -0
- package/core/color/hsv2rgb.js +54 -0
- package/core/color/int2rgb.js +12 -0
- package/core/color/parseHex.js +18 -0
- package/core/color/rgb2hex.js +16 -0
- package/core/color/rgb2hsv.js +47 -0
- package/core/color/rgb2uint24.js +17 -0
- package/core/color/rgb_to_YCbCr_uint24.js +18 -0
- package/core/geom/3d/aabb/compute_aabb_from_points.js +28 -0
- package/core/geom/3d/plane/orient3d_fast.js +45 -0
- package/core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js +5 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.js +177 -0
- package/core/geom/3d/tetrahedra/compute_bounding_simplex_3d.spec.js +66 -0
- package/core/geom/3d/tetrahedra/compute_circumsphere.js +271 -0
- package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.js +199 -0
- package/core/geom/3d/tetrahedra/compute_delaunay_tetrahedral_mesh.spec.js +5 -0
- package/core/geom/3d/tetrahedra/point_in_tetrahedron_circumsphere.js +77 -0
- package/core/geom/3d/tetrahedra/tetrahedron_contains_point.js +25 -0
- package/core/geom/Quaternion.js +4 -0
- package/core/math/hash/murmur3_32.js +39 -0
- package/core/process/undo/ActionProcessor.d.ts +2 -0
- package/core/process/undo/ActionProcessor.js +8 -0
- package/editor/tools/FoliagePaintTool.js +1 -1
- package/editor/tools/GridPaintTool.js +1 -1
- package/engine/ecs/foliage/InstancedFoliage.js +45 -0
- package/engine/ecs/foliage/ecs/InstancedMeshLayer.js +4 -0
- package/engine/ecs/storage/BinaryBufferSerializer.js +48 -38
- package/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +1 -1
- package/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
- package/engine/graphics/GraphicsEngine.js +7 -0
- package/engine/graphics/ecs/mesh/Mesh.js +2 -2
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +13 -0
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +339 -314
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +6 -2
- package/engine/graphics/particles/node-based/rendering/billboard/ParticleBillboardShader.js +1 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +100 -55
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +6 -1
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +1 -0
- package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +1 -1
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +17 -4
- package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
- package/engine/graphics/render/visibility/VisibilityComputer.js +8 -7
- package/engine/graphics/shaders/TerrainShader.js +5 -5
- package/engine/graphics/shadows/testShadowMapRendering.js +192 -0
- package/package.json +2 -1
- package/view/elements/ColorPickerView.js +2 -1
|
@@ -122,6 +122,7 @@ export class VGThreeRenderer {
|
|
|
122
122
|
// clear contexts
|
|
123
123
|
const contexts = this.__contexts_array;
|
|
124
124
|
const context_count = contexts.length;
|
|
125
|
+
|
|
125
126
|
for (let i = 0; i < context_count; i++) {
|
|
126
127
|
const ctx = contexts[i];
|
|
127
128
|
|
|
@@ -142,8 +143,11 @@ export class VGThreeRenderer {
|
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
const inputs = this.__inputs;
|
|
147
|
+
const input_count = inputs.length;
|
|
148
|
+
|
|
149
|
+
for (let i = 0; i < input_count; i++) {
|
|
150
|
+
const input_object = inputs[i];
|
|
147
151
|
|
|
148
152
|
input_object.traverse(processObject);
|
|
149
153
|
}
|
package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js
CHANGED
|
@@ -17,9 +17,9 @@ const CHUNK_LAMBERT_LIGHTING = `
|
|
|
17
17
|
vec3 diffuse = vec3( 1.0 );
|
|
18
18
|
|
|
19
19
|
GeometricContext geometry;
|
|
20
|
-
geometry.position =
|
|
20
|
+
geometry.position = -vViewPosition;
|
|
21
21
|
geometry.normal = normalize( transformedNormal );
|
|
22
|
-
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -
|
|
22
|
+
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -vViewPosition.xyz );
|
|
23
23
|
|
|
24
24
|
GeometricContext backGeometry;
|
|
25
25
|
backGeometry.position = geometry.position;
|
|
@@ -156,28 +156,11 @@ function make_vertex_shader() {
|
|
|
156
156
|
varying vec2 vRotationMultiplier;
|
|
157
157
|
varying float vBlending;
|
|
158
158
|
|
|
159
|
-
|
|
160
159
|
#if defined(LIGHTS_ENABLED)
|
|
161
|
-
|
|
162
|
-
#include <bsdfs>
|
|
163
|
-
#include <lights_pars_begin>
|
|
164
|
-
|
|
165
|
-
struct LambertMaterial {
|
|
166
|
-
vec3 diffuseColor;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
170
|
-
vec3 irradiance = directLight.color;
|
|
171
|
-
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
175
|
-
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
#define RE_Direct RE_Direct_Lambert
|
|
179
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
|
|
160
|
+
varying vec3 vViewPosition;
|
|
180
161
|
#endif
|
|
162
|
+
|
|
163
|
+
|
|
181
164
|
|
|
182
165
|
void main() {
|
|
183
166
|
|
|
@@ -194,10 +177,11 @@ function make_vertex_shader() {
|
|
|
194
177
|
|
|
195
178
|
#if defined(LIGHTS_ENABLED)
|
|
196
179
|
vec4 mvPosition = modelViewMatrix * position4;
|
|
197
|
-
|
|
180
|
+
vViewPosition = -mvPosition.xyz;
|
|
198
181
|
|
|
199
182
|
vec3 transformedNormal = vec3(0.0,0.0,1.0);
|
|
200
|
-
|
|
183
|
+
|
|
184
|
+
#include <worldpos_vertex>
|
|
201
185
|
#endif
|
|
202
186
|
|
|
203
187
|
gl_Position = modelViewProjectionMatrix * position4;
|
|
@@ -222,7 +206,6 @@ function make_vertex_shader() {
|
|
|
222
206
|
|
|
223
207
|
}
|
|
224
208
|
#endif
|
|
225
|
-
//
|
|
226
209
|
|
|
227
210
|
vRotationMultiplier = vec2( cos(rotationGlobal),sin(rotationGlobal) );
|
|
228
211
|
|
|
@@ -238,30 +221,6 @@ function make_vertex_shader() {
|
|
|
238
221
|
|
|
239
222
|
gl_PointSize = projected_radius;
|
|
240
223
|
|
|
241
|
-
#if defined(LIGHTS_ENABLED)
|
|
242
|
-
vec3 vLightFront;
|
|
243
|
-
vec3 vIndirectFront;
|
|
244
|
-
|
|
245
|
-
#include <worldpos_vertex>
|
|
246
|
-
${CHUNK_LAMBERT_LIGHTING}
|
|
247
|
-
|
|
248
|
-
LambertMaterial material = LambertMaterial(vColor.rgb);
|
|
249
|
-
|
|
250
|
-
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
251
|
-
vec3 totalEmissiveRadiance = vec3(0.0);
|
|
252
|
-
|
|
253
|
-
reflectedLight.indirectDiffuse += vIndirectFront;
|
|
254
|
-
reflectedLight.indirectDiffuse *= BRDF_Lambert( vColor.rgb );
|
|
255
|
-
|
|
256
|
-
reflectedLight.directDiffuse = vLightFront;
|
|
257
|
-
reflectedLight.directDiffuse *= BRDF_Lambert( vColor.rgb ); // shadowmask goes here
|
|
258
|
-
|
|
259
|
-
//@injection_point FORWARD_PLUS:accumulation
|
|
260
|
-
|
|
261
|
-
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
262
|
-
|
|
263
|
-
vColor.rgb = outgoingLight;
|
|
264
|
-
#endif
|
|
265
224
|
|
|
266
225
|
}`;
|
|
267
226
|
}
|
|
@@ -276,6 +235,10 @@ function make_fragment_shader() {
|
|
|
276
235
|
uniform float cameraFar;
|
|
277
236
|
uniform mat4 modelViewMatrix;
|
|
278
237
|
uniform mat4 projectionMatrix;
|
|
238
|
+
|
|
239
|
+
uniform mat4 uProjectionInverse;
|
|
240
|
+
uniform mat4 uViewInverse;
|
|
241
|
+
|
|
279
242
|
uniform vec2 resolution;
|
|
280
243
|
|
|
281
244
|
varying float vFadeDistance;
|
|
@@ -285,7 +248,6 @@ function make_fragment_shader() {
|
|
|
285
248
|
varying vec2 vRotationMultiplier;
|
|
286
249
|
varying float vBlending;
|
|
287
250
|
|
|
288
|
-
|
|
289
251
|
out highp vec4 pc_fragColor;
|
|
290
252
|
|
|
291
253
|
float depthToLinear( float z ) {
|
|
@@ -334,6 +296,58 @@ function make_fragment_shader() {
|
|
|
334
296
|
return zFade;
|
|
335
297
|
}
|
|
336
298
|
|
|
299
|
+
|
|
300
|
+
#if defined(LIGHTS_ENABLED)
|
|
301
|
+
|
|
302
|
+
vec3 computeWorldPositionFromFragmentPosition(vec3 coord){
|
|
303
|
+
vec4 ndc = vec4(
|
|
304
|
+
(coord.x - 0.5) * 2.0,
|
|
305
|
+
(coord.y - 0.5) * 2.0,
|
|
306
|
+
(coord.z - 0.5) * 2.0,
|
|
307
|
+
1.0);
|
|
308
|
+
|
|
309
|
+
vec4 clip = uProjectionInverse * ndc;
|
|
310
|
+
return (uViewInverse* (clip / clip.w) ).xyz;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
vec3 construct_spherical_normal_from_point_coord(vec2 coord){
|
|
314
|
+
float x = coord.x * 2.0 - 1.0;
|
|
315
|
+
float y = coord.y * 2.0 - 1.0; // note we flip Y
|
|
316
|
+
|
|
317
|
+
float z = sqrt(1.0 - clamp(x*x + y*y, 0.0, 1.0));
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
vec3 position = vec3(x, -y, z);
|
|
321
|
+
|
|
322
|
+
vec3 normal = normalize(position);
|
|
323
|
+
|
|
324
|
+
return normal;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
#include <common>
|
|
328
|
+
#include <bsdfs>
|
|
329
|
+
#include <lights_pars_begin>
|
|
330
|
+
|
|
331
|
+
struct LambertMaterial {
|
|
332
|
+
vec3 diffuseColor;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
336
|
+
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
337
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
338
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
342
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
#define RE_Direct RE_Direct_Lambert
|
|
346
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert
|
|
347
|
+
|
|
348
|
+
varying vec3 vViewPosition;
|
|
349
|
+
#endif
|
|
350
|
+
|
|
337
351
|
void main() {
|
|
338
352
|
float fragmentDepth = gl_FragCoord.z;
|
|
339
353
|
|
|
@@ -365,6 +379,37 @@ function make_fragment_shader() {
|
|
|
365
379
|
|
|
366
380
|
vec4 texel = spriteColor * vColor;
|
|
367
381
|
|
|
382
|
+
#if defined(LIGHTS_ENABLED)
|
|
383
|
+
// compute world position
|
|
384
|
+
vec3 v_world_position = computeWorldPositionFromFragmentPosition(gl_FragCoord.xyz);
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
vec3 vLightFront;
|
|
388
|
+
vec3 vIndirectFront;
|
|
389
|
+
|
|
390
|
+
vec3 transformedNormal = construct_spherical_normal_from_point_coord(gl_PointCoord.xy);
|
|
391
|
+
|
|
392
|
+
${CHUNK_LAMBERT_LIGHTING}
|
|
393
|
+
|
|
394
|
+
LambertMaterial material = LambertMaterial(texel.rgb);
|
|
395
|
+
|
|
396
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
397
|
+
vec3 totalEmissiveRadiance = vec3(0.0);
|
|
398
|
+
|
|
399
|
+
reflectedLight.indirectDiffuse += vIndirectFront;
|
|
400
|
+
reflectedLight.indirectDiffuse *= BRDF_Lambert( texel.rgb );
|
|
401
|
+
|
|
402
|
+
reflectedLight.directDiffuse = vLightFront;
|
|
403
|
+
reflectedLight.directDiffuse *= BRDF_Lambert( texel.rgb ); // shadowmask goes here
|
|
404
|
+
|
|
405
|
+
//@injection_point FORWARD_PLUS:accumulation
|
|
406
|
+
|
|
407
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
408
|
+
|
|
409
|
+
texel.rgb = outgoingLight;
|
|
410
|
+
#endif
|
|
411
|
+
|
|
412
|
+
|
|
368
413
|
// premultiply alpha
|
|
369
414
|
texel.xyz *= texel.a;
|
|
370
415
|
|
|
@@ -379,9 +424,8 @@ function make_fragment_shader() {
|
|
|
379
424
|
texel *= zFade;
|
|
380
425
|
|
|
381
426
|
#endif
|
|
382
|
-
|
|
383
|
-
pc_fragColor = texel;
|
|
384
427
|
|
|
428
|
+
pc_fragColor = texel;
|
|
385
429
|
}`;
|
|
386
430
|
}
|
|
387
431
|
|
|
@@ -426,7 +470,9 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
|
|
|
426
470
|
resolution: {
|
|
427
471
|
type: 'v2',
|
|
428
472
|
value: new ThreeVector2()
|
|
429
|
-
}
|
|
473
|
+
},
|
|
474
|
+
uViewInverse: { type: 'm4', value: new Matrix4() },
|
|
475
|
+
uProjectionInverse: { type: 'm4', value: new Matrix4() },
|
|
430
476
|
};
|
|
431
477
|
|
|
432
478
|
if (lights) {
|
|
@@ -439,8 +485,7 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
|
|
|
439
485
|
DEPTH_READ_ENABLED: true,
|
|
440
486
|
DEPTH_SOFT_ENABLED: true,
|
|
441
487
|
ALIGN_DIRECTION_ENABLED: false,
|
|
442
|
-
LIGHTS_ENABLED: lights
|
|
443
|
-
LIGHTING_VERTEX_ONLY: true
|
|
488
|
+
LIGHTS_ENABLED: lights
|
|
444
489
|
},
|
|
445
490
|
uniforms: uniforms,
|
|
446
491
|
vertexShader: make_vertex_shader(),
|
|
@@ -189,7 +189,9 @@ export class ShaderManager {
|
|
|
189
189
|
},
|
|
190
190
|
cameraFar: {
|
|
191
191
|
value: 0
|
|
192
|
-
}
|
|
192
|
+
},
|
|
193
|
+
uViewInverse: { type: 'm4', value: new Matrix4() },
|
|
194
|
+
uProjectionInverse: { type: 'm4', value: new Matrix4() },
|
|
193
195
|
};
|
|
194
196
|
|
|
195
197
|
// debugAtlas(this.spriteAtlas.atlas, { scale: new Vector2(1, 1) });
|
|
@@ -396,6 +398,9 @@ export class ShaderManager {
|
|
|
396
398
|
uniforms.modelViewMatrix.value = modelViewMatrix;
|
|
397
399
|
uniforms.cameraNear.value = cameraNear;
|
|
398
400
|
uniforms.cameraFar.value = cameraFar;
|
|
401
|
+
|
|
402
|
+
uniforms.uProjectionInverse.value.copy(camera.projectionMatrixInverse);
|
|
403
|
+
uniforms.uViewInverse.value.copy(camera.matrixWorld);
|
|
399
404
|
}
|
|
400
405
|
|
|
401
406
|
/**
|
|
@@ -15,10 +15,8 @@ const accumulation_pars = `
|
|
|
15
15
|
const preamble = `
|
|
16
16
|
${FP_SHADER_CHUNK_PREAMBLE}
|
|
17
17
|
|
|
18
|
-
varying vec3 v_world_position;
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
#define gl_FragColor pc_fragColor
|
|
19
|
+
|
|
22
20
|
`;
|
|
23
21
|
|
|
24
22
|
/**
|
|
@@ -27,7 +25,22 @@ const preamble = `
|
|
|
27
25
|
* @returns {string}
|
|
28
26
|
*/
|
|
29
27
|
export function fp_build_fragment_shader(base) {
|
|
30
|
-
let result = preamble
|
|
28
|
+
let result = preamble;
|
|
29
|
+
|
|
30
|
+
if (base.indexOf('v_world_position') === -1) {
|
|
31
|
+
result = result + `
|
|
32
|
+
varying vec3 v_world_position;
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (base.indexOf('#define gl_FragColor') === -1 && base.indexOf('pc_fragColor') === -1) {
|
|
37
|
+
result = result + `
|
|
38
|
+
out highp vec4 pc_fragColor;
|
|
39
|
+
#define gl_FragColor pc_fragColor
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result = result + base
|
|
31
44
|
|
|
32
45
|
result = insert_after(result, '#include <lights_pars_begin>', FP_SHADER_CHUNK_DECODE_PARS);
|
|
33
46
|
|
|
@@ -9,6 +9,12 @@ const frustum = new Frustum();
|
|
|
9
9
|
*/
|
|
10
10
|
const objectFilters = [];
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {function[]}
|
|
15
|
+
*/
|
|
16
|
+
const objectFilterExecutors = [];
|
|
17
|
+
|
|
12
18
|
export const SOURCE_RENDER_LAYER_PROPERTY = '@meep-render-layer';
|
|
13
19
|
|
|
14
20
|
export class VisibilityComputer {
|
|
@@ -135,12 +141,6 @@ export class VisibilityComputer {
|
|
|
135
141
|
// clear visible set
|
|
136
142
|
// this.__output.initializeUpdate();
|
|
137
143
|
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
* @type {function[]}
|
|
141
|
-
*/
|
|
142
|
-
const objectFilterExecutors = [];
|
|
143
|
-
|
|
144
144
|
const filters = this.filters;
|
|
145
145
|
const filterCount = filters.length;
|
|
146
146
|
|
|
@@ -151,7 +151,7 @@ export class VisibilityComputer {
|
|
|
151
151
|
|
|
152
152
|
if (f.enabled && f.layerPredicate(layer)) {
|
|
153
153
|
objectFilters[objectFilterCount] = f;
|
|
154
|
-
objectFilterExecutors
|
|
154
|
+
objectFilterExecutors[objectFilterCount] = f.objectPredicateExecute;
|
|
155
155
|
|
|
156
156
|
objectFilterCount++;
|
|
157
157
|
}
|
|
@@ -165,6 +165,7 @@ export class VisibilityComputer {
|
|
|
165
165
|
f.objectPredicateInitialize(this.__view.camera);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
objectFilterExecutors.length = objectFilterCount;
|
|
168
169
|
|
|
169
170
|
layer.buildVisibleSet(this.__frustums, objectFilterExecutors, this.__includeObject, this);
|
|
170
171
|
|
|
@@ -366,27 +366,27 @@ function fragment() {
|
|
|
366
366
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
367
367
|
|
|
368
368
|
#if defined( TONE_MAPPING )
|
|
369
|
-
gl_FragColor.rgb = toneMapping(
|
|
369
|
+
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
370
370
|
#endif
|
|
371
371
|
|
|
372
372
|
//encode fragment
|
|
373
|
-
|
|
373
|
+
gl_FragColor = linearToOutputTexel( gl_FragColor );
|
|
374
374
|
#ifdef USE_FOG
|
|
375
375
|
#ifdef FOG_EXP2
|
|
376
376
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
|
|
377
377
|
#else
|
|
378
378
|
float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
|
|
379
379
|
#endif
|
|
380
|
-
gl_FragColor.rgb = mix(
|
|
380
|
+
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
381
381
|
#endif
|
|
382
382
|
|
|
383
383
|
#ifdef PREMULTIPLIED_ALPHA
|
|
384
384
|
// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
|
|
385
|
-
gl_FragColor.rgb *=
|
|
385
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
386
386
|
#endif
|
|
387
387
|
|
|
388
388
|
#ifdef DITHERING
|
|
389
|
-
|
|
389
|
+
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
390
390
|
#endif
|
|
391
391
|
}
|
|
392
392
|
`;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { EngineHarness } from "../../EngineHarness.js";
|
|
2
|
+
import { loadSerializedScene } from "../../scene/SerializedScene.js";
|
|
3
|
+
import { EngineConfiguration } from "../../EngineConfiguration.js";
|
|
4
|
+
import { MeshSystem } from "../ecs/mesh/MeshSystem.js";
|
|
5
|
+
import GUIElementSystem from "../../ecs/gui/GUIElementSystem.js";
|
|
6
|
+
import HeadsUpDisplaySystem from "../../ecs/gui/hud/HeadsUpDisplaySystem.js";
|
|
7
|
+
import TagSystem from "../../ecs/systems/TagSystem.js";
|
|
8
|
+
import { AttachmentSocketsSystem } from "../../ecs/sockets/AttachmentSocketsSystem.js";
|
|
9
|
+
import { AttachmentSystem } from "../../ecs/attachment/AttachmentSystem.js";
|
|
10
|
+
import { SoundEmitterSystem } from "../../sound/ecs/emitter/SoundEmitterSystem.js";
|
|
11
|
+
import SoundControllerSystem from "../../sound/ecs/SoundControllerSystem.js";
|
|
12
|
+
import SoundListenerSystem from "../../sound/ecs/SoundListenerSystem.js";
|
|
13
|
+
import AnimationSystem from "../../ecs/systems/AnimationSystem.js";
|
|
14
|
+
import TopDownCameraControllerSystem from "../ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
15
|
+
import { CameraSystem } from "../ecs/camera/CameraSystem.js";
|
|
16
|
+
import ClingToTerrainSystem from "../../ecs/terrain/ecs/ClingToTerrainSystem.js";
|
|
17
|
+
import TerrainSystem from "../../ecs/terrain/ecs/TerrainSystem.js";
|
|
18
|
+
import Trail2DSystem from "../ecs/trail2d/Trail2DSystem.js";
|
|
19
|
+
import { Foliage2System } from "../../ecs/foliage/ecs/Foliage2System.js";
|
|
20
|
+
import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
|
|
21
|
+
import SynchronizePositionSystem from "../../ecs/systems/SynchronizePositionSystem.js";
|
|
22
|
+
import InputControllerSystem from "../../input/ecs/systems/InputControllerSystem.js";
|
|
23
|
+
import { InputSystem } from "../../input/ecs/systems/InputSystem.js";
|
|
24
|
+
import MeshHighlightSystem from "../ecs/highlight/system/MeshHighlightSystem.js";
|
|
25
|
+
import LightSystem from "../ecs/light/LightSystem.js";
|
|
26
|
+
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
27
|
+
import { SerializationMetadataSystem } from "../../ecs/systems/SerializationMetadataSystem.js";
|
|
28
|
+
import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
|
|
29
|
+
import { ParticleEmitterSystem } from "../particles/ecs/ParticleEmitterSystem.js";
|
|
30
|
+
import { ShadedGeometrySystem } from "../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
31
|
+
import { ArrayBufferLoader } from "../../asset/loaders/ArrayBufferLoader.js";
|
|
32
|
+
import { initializeGameBinarySerializationRegistry } from "../../../../model/game/GameBinarySerializationRegistry.js";
|
|
33
|
+
import WaterSystem from "../ecs/water/WaterSystem.js";
|
|
34
|
+
import Army from "../../../../model/game/ecs/component/army/Army.js";
|
|
35
|
+
import Mesh from "../ecs/mesh/Mesh.js";
|
|
36
|
+
import EntityBuilder from "../../ecs/EntityBuilder.js";
|
|
37
|
+
import { buildCanvasViewFromTexture } from "../render/visibility/hiz/buildCanvasViewFromTexture.js";
|
|
38
|
+
import ViewportPosition from "../../ecs/gui/position/ViewportPosition.js";
|
|
39
|
+
import Vector2 from "../../../core/geom/Vector2.js";
|
|
40
|
+
import GUIElement from "../../ecs/gui/GUIElement.js";
|
|
41
|
+
import { enableEditor } from "../../../editor/enableEditor.js";
|
|
42
|
+
import { SerializationMetadata } from "../../ecs/components/SerializationMetadata.js";
|
|
43
|
+
|
|
44
|
+
const eh = new EngineHarness();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {Engine} engine
|
|
49
|
+
* @returns {EngineConfiguration}
|
|
50
|
+
*/
|
|
51
|
+
function makeConfig(engine) {
|
|
52
|
+
|
|
53
|
+
const config = new EngineConfiguration();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @type {SoundEngine}
|
|
58
|
+
*/
|
|
59
|
+
const sound = engine.sound;
|
|
60
|
+
const graphics = engine.graphics;
|
|
61
|
+
const assetManager = engine.assetManager;
|
|
62
|
+
const devices = engine.devices;
|
|
63
|
+
|
|
64
|
+
// graphics.renderer.shadowMap.type = BasicShadowMap;
|
|
65
|
+
|
|
66
|
+
const guiSystem = new GUIElementSystem(engine.gui.view, engine);
|
|
67
|
+
const headsUpDisplaySystem = new HeadsUpDisplaySystem(graphics);
|
|
68
|
+
|
|
69
|
+
config.addLoader('arraybuffer', new ArrayBufferLoader());
|
|
70
|
+
|
|
71
|
+
initializeGameBinarySerializationRegistry(engine.binarySerializationRegistry);
|
|
72
|
+
|
|
73
|
+
config.addManySystems(
|
|
74
|
+
new TagSystem(),
|
|
75
|
+
new AttachmentSocketsSystem(),
|
|
76
|
+
new AttachmentSystem(),
|
|
77
|
+
new SoundEmitterSystem(assetManager, sound.destination, sound.context),
|
|
78
|
+
new SoundControllerSystem(),
|
|
79
|
+
new SoundListenerSystem(sound.context),
|
|
80
|
+
guiSystem,
|
|
81
|
+
new AnimationSystem(graphics.viewport.size),
|
|
82
|
+
new TopDownCameraControllerSystem(graphics),
|
|
83
|
+
new CameraSystem(graphics.scene, graphics),
|
|
84
|
+
new MeshSystem(engine),
|
|
85
|
+
new ClingToTerrainSystem(),
|
|
86
|
+
new TerrainSystem(graphics, assetManager),
|
|
87
|
+
new Trail2DSystem(engine),
|
|
88
|
+
new Foliage2System(assetManager, graphics),
|
|
89
|
+
new ViewportPositionSystem(graphics.viewport.size),
|
|
90
|
+
new SynchronizePositionSystem(),
|
|
91
|
+
new InputControllerSystem(devices),
|
|
92
|
+
new InputSystem(devices),
|
|
93
|
+
new MeshHighlightSystem(engine),
|
|
94
|
+
new LightSystem(engine, {
|
|
95
|
+
shadowResolution: 2048
|
|
96
|
+
}),
|
|
97
|
+
headsUpDisplaySystem,
|
|
98
|
+
new BehaviorSystem(engine),
|
|
99
|
+
new SerializationMetadataSystem(),
|
|
100
|
+
new PathDisplaySystem(engine),
|
|
101
|
+
new ParticleEmitterSystem(engine),
|
|
102
|
+
new ShadedGeometrySystem(engine),
|
|
103
|
+
new WaterSystem(graphics)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
// Knowledge
|
|
108
|
+
|
|
109
|
+
return config;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {Engine} engine
|
|
115
|
+
*/
|
|
116
|
+
function get_three_light(engine) {
|
|
117
|
+
|
|
118
|
+
return engine.graphics.scene.children.find(l => l.isDirectionalLight);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param {Engine} engine
|
|
124
|
+
*/
|
|
125
|
+
function init_shadowmap_preview(engine) {
|
|
126
|
+
const ecd = engine.entityManager.dataset;
|
|
127
|
+
|
|
128
|
+
const graphics = engine.graphics;
|
|
129
|
+
const preview = buildCanvasViewFromTexture({
|
|
130
|
+
width: 512,
|
|
131
|
+
height: 512,
|
|
132
|
+
renderer: graphics.renderer,
|
|
133
|
+
texture: null
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
graphics.on.postOpaquePass.add(() => {
|
|
137
|
+
|
|
138
|
+
const light = get_three_light(engine);
|
|
139
|
+
|
|
140
|
+
if (light !== undefined) {
|
|
141
|
+
preview.texture = light.shadow.map.texture;
|
|
142
|
+
|
|
143
|
+
preview.render();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
new EntityBuilder()
|
|
149
|
+
.add(ViewportPosition.fromJSON({
|
|
150
|
+
offset: new Vector2(10, 10)
|
|
151
|
+
}))
|
|
152
|
+
.add(GUIElement.fromView(preview.view))
|
|
153
|
+
.add(SerializationMetadata.Transient)
|
|
154
|
+
.build(ecd);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param {Engine} engine
|
|
160
|
+
* @returns {Promise<void>}
|
|
161
|
+
*/
|
|
162
|
+
async function main(engine) {
|
|
163
|
+
|
|
164
|
+
const ecd = engine.entityManager.dataset;
|
|
165
|
+
await loadSerializedScene('data/levels/character_creation/level.bin', ecd, engine);
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
const character = ecd.getAnyComponent(Army);
|
|
169
|
+
|
|
170
|
+
const entity = EntityBuilder.readFromDataset(character.entity, ecd);
|
|
171
|
+
|
|
172
|
+
entity.getComponent(Mesh).url = "data/models/Conqueror Mech/Conqueror Mech.gltf";
|
|
173
|
+
|
|
174
|
+
init_shadowmap_preview(engine);
|
|
175
|
+
|
|
176
|
+
window.light = get_three_light(engine);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function init(engineHarness) {
|
|
180
|
+
|
|
181
|
+
const engine = await engineHarness.initialize();
|
|
182
|
+
|
|
183
|
+
const config = makeConfig(engine);
|
|
184
|
+
|
|
185
|
+
await config.apply(engine);
|
|
186
|
+
|
|
187
|
+
enableEditor(engine);
|
|
188
|
+
|
|
189
|
+
main(engine);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
init(eh);
|
package/package.json
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.33.
|
|
8
|
+
"version": "2.33.37",
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"gl-matrix": "3.4.3",
|
|
10
11
|
"fast-levenshtein": "2.0.6",
|
|
11
12
|
"opentype.js": "1.3.3",
|
|
12
13
|
"simplex-noise": "2.4.0",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { hsv2rgb, rgb2hsv } from "../../core/color/ColorUtils.js";
|
|
2
1
|
import GuiControl from "../controller/controls/GuiControl.js";
|
|
3
2
|
import { GaugeView } from "../../editor/view/ecs/components/color/GaugeView.js";
|
|
4
3
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
5
4
|
import { drawCheckers } from "../../editor/view/ecs/components/particles/ColorParameterLUTController.js";
|
|
5
|
+
import { hsv2rgb } from "../../core/color/hsv2rgb.js";
|
|
6
|
+
import { rgb2hsv } from "../../core/color/rgb2hsv.js";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
export class ColorPickerView extends GuiControl {
|