@woosh/meep-engine 2.33.33 → 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/geom/Vector2.d.ts +8 -0
- package/core/geom/Vector3.d.ts +8 -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/build/PatchRepresentation.js +1 -1
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -1
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
- package/engine/graphics/micron/format/serialization/deserialize_patch.js +1 -1
- package/engine/graphics/micron/format/serialization/serialize_patch.js +1 -1
- package/engine/graphics/micron/render/instanced/PatchDataTextures.js +3 -3
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -1
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +1 -1
- package/engine/graphics/micron/render/makeThreeMeshFromVirtualGeometry.js +1 -1
- package/engine/graphics/micron/render/v1/MaterialContext.js +11 -2
- package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +2 -2
- package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +7 -3
- 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 +5 -3
- package/view/elements/ColorPickerView.js +2 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approximate 3D insphere test. Nonrobust.
|
|
3
|
+
*
|
|
4
|
+
* Return a positive value if the point pe lies inside the
|
|
5
|
+
* sphere passing through pa, pb, pc, and pd; a negative value
|
|
6
|
+
* if it lies outside; and zero if the five points are
|
|
7
|
+
* cospherical. The points pa, pb, pc, and pd must be ordered
|
|
8
|
+
* so that they have a positive orientation (as defined by
|
|
9
|
+
* orient3d()), or the sign of the result will be reversed.
|
|
10
|
+
*
|
|
11
|
+
* @see "Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates." Technical Report CMU-CS-96-140, School of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania, May 1996
|
|
12
|
+
* @see http://www.cs.cmu.edu/~quake/robust.html
|
|
13
|
+
* @see https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/contrib/hxt/predicates/src/predicates.c
|
|
14
|
+
* @param {number[]} points
|
|
15
|
+
* @param {number} a tetrahedral point index
|
|
16
|
+
* @param {number} b tetrahedral point index
|
|
17
|
+
* @param {number} c tetrahedral point index
|
|
18
|
+
* @param {number} d tetrahedral point index
|
|
19
|
+
* @param {number} e reference point index
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
export function point_in_tetrahedron_circumsphere(points, a, b, c, d, e) {
|
|
23
|
+
const ex = points[e * 3];
|
|
24
|
+
const ey = points[e * 3 + 1];
|
|
25
|
+
const ez = points[e * 3 + 2];
|
|
26
|
+
|
|
27
|
+
const aex = points[a * 3] - ex;
|
|
28
|
+
const bex = points[b * 3] - ex;
|
|
29
|
+
const cex = points[c * 3] - ex;
|
|
30
|
+
const dex = points[d * 3] - ex;
|
|
31
|
+
|
|
32
|
+
const aey = points[a * 3 + 1] - ey;
|
|
33
|
+
const bey = points[b * 3 + 1] - ey;
|
|
34
|
+
const cey = points[c * 3 + 1] - ey;
|
|
35
|
+
const dey = points[d * 3 + 1] - ey;
|
|
36
|
+
|
|
37
|
+
const aez = points[a * 3 + 2] - ez;
|
|
38
|
+
const bez = points[b * 3 + 2] - ez;
|
|
39
|
+
const cez = points[c * 3 + 2] - ez;
|
|
40
|
+
const dez = points[d * 3 + 1] - ez;
|
|
41
|
+
|
|
42
|
+
const aexbey = aex * bey;
|
|
43
|
+
const bexaey = bex * aey;
|
|
44
|
+
const ab = aexbey - bexaey;
|
|
45
|
+
const bexcey = bex * cey;
|
|
46
|
+
const cexbey = cex * bey;
|
|
47
|
+
const bc = bexcey - cexbey;
|
|
48
|
+
const cexdey = cex * dey;
|
|
49
|
+
const dexcey = dex * cey;
|
|
50
|
+
const cd = cexdey - dexcey;
|
|
51
|
+
const dexaey = dex * aey;
|
|
52
|
+
const aexdey = aex * dey;
|
|
53
|
+
const da = dexaey - aexdey;
|
|
54
|
+
|
|
55
|
+
const aexcey = aex * cey;
|
|
56
|
+
const cexaey = cex * aey;
|
|
57
|
+
const ac = aexcey - cexaey;
|
|
58
|
+
const bexdey = bex * dey;
|
|
59
|
+
const dexbey = dex * bey;
|
|
60
|
+
const bd = bexdey - dexbey;
|
|
61
|
+
|
|
62
|
+
const abc = aez * bc - bez * ac + cez * ab;
|
|
63
|
+
const bcd = bez * cd - cez * bd + dez * bc;
|
|
64
|
+
const cda = cez * da + dez * ac + aez * cd;
|
|
65
|
+
const dab = dez * ab + aez * bd + bez * da;
|
|
66
|
+
|
|
67
|
+
const alift = aex * aex + aey * aey + aez * aez;
|
|
68
|
+
const blift = bex * bex + bey * bey + bez * bez;
|
|
69
|
+
const clift = cex * cex + cey * cey + cez * cez;
|
|
70
|
+
const dlift = dex * dex + dey * dey + dez * dez;
|
|
71
|
+
|
|
72
|
+
const det = (dlift * abc - clift * dab) + (blift * cda - alift * bcd);
|
|
73
|
+
|
|
74
|
+
// TODO HXT uses 2 more methods to perform exact calculation (avoiding rounding errors), we could include that if necessary
|
|
75
|
+
|
|
76
|
+
return det;
|
|
77
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { orient3d_fast } from "../plane/orient3d_fast.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Containment test, whether tetrahedron defined by A,B,C,D contains point E or not
|
|
5
|
+
* Implemented using planar tests on each of side of the tetrahedron
|
|
6
|
+
*
|
|
7
|
+
* NOTE: similar to https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/contrib/hxt/tetMesh/src/HXTSPR.c
|
|
8
|
+
* We skip identity checks and bounding box checks. Identity is a waste of time when building tetrahedral mesh,
|
|
9
|
+
* since each inserted point will be new to the mesh, box checks are not relevant as we don't track those
|
|
10
|
+
*
|
|
11
|
+
* @param {number[]} points
|
|
12
|
+
* @param {number} a
|
|
13
|
+
* @param {number} b
|
|
14
|
+
* @param {number} c
|
|
15
|
+
* @param {number} d
|
|
16
|
+
* @param {number} e
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
export function tetrahedron_contains_point(points, a, b, c, d, e) {
|
|
20
|
+
return !(orient3d_fast(points, b, d, c, e) > 0
|
|
21
|
+
|| orient3d_fast(points, c, d, a, e) > 0
|
|
22
|
+
|| orient3d_fast(points, d, b, a, e) > 0
|
|
23
|
+
|| orient3d_fast(points, a, b, c, e) > 0
|
|
24
|
+
);
|
|
25
|
+
}
|
package/core/geom/Quaternion.js
CHANGED
|
@@ -1298,6 +1298,10 @@ class Quaternion {
|
|
|
1298
1298
|
this.set(x, y, z, w);
|
|
1299
1299
|
}
|
|
1300
1300
|
|
|
1301
|
+
/**
|
|
1302
|
+
* Based on GDC talk from Bungie on destiny, compressing quaternions for animation
|
|
1303
|
+
* @param value
|
|
1304
|
+
*/
|
|
1301
1305
|
decodeFromUint32(value) {
|
|
1302
1306
|
//read components
|
|
1303
1307
|
const max = value & 0x3;
|
package/core/geom/Vector2.d.ts
CHANGED
package/core/geom/Vector3.d.ts
CHANGED
|
@@ -31,6 +31,14 @@ export default class Vector3 implements Vector3Like {
|
|
|
31
31
|
|
|
32
32
|
_sub(x: number, y: number, z: number): void
|
|
33
33
|
|
|
34
|
+
abs(): void
|
|
35
|
+
|
|
36
|
+
round(): void
|
|
37
|
+
|
|
38
|
+
floor(): void
|
|
39
|
+
|
|
40
|
+
ceil(): void
|
|
41
|
+
|
|
34
42
|
_multiply(x: number, y: number, z: number): void
|
|
35
43
|
|
|
36
44
|
multiply(other: Vector3Like): void
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: based on https://github.com/garycourt/murmurhash-js/blob/master/murmurhash3_gc.js
|
|
3
|
+
* @param {Uint32Array} key
|
|
4
|
+
* @param {number} seed
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function murmur3_32(key, seed) {
|
|
8
|
+
let h1 = seed;
|
|
9
|
+
let k1;
|
|
10
|
+
let i = 0;
|
|
11
|
+
|
|
12
|
+
const bytes = key.length;
|
|
13
|
+
|
|
14
|
+
while (i < bytes) {
|
|
15
|
+
k1 = key[i];
|
|
16
|
+
++i;
|
|
17
|
+
|
|
18
|
+
k1 = ((((k1 & 0xffff) * 0xcc9e2d51) + ((((k1 >>> 16) * 0xcc9e2d51) & 0xffff) << 16)));
|
|
19
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
|
20
|
+
k1 = ((((k1 & 0xffff) * 0x1b873593) + ((((k1 >>> 16) * 0x1b873593) & 0xffff) << 16)));
|
|
21
|
+
|
|
22
|
+
h1 ^= k1;
|
|
23
|
+
h1 = (h1 << 13) | (h1 >>> 19);
|
|
24
|
+
h1 = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16)));
|
|
25
|
+
h1 = (((h1 & 0xffff) + 0x6b64) + ((((h1 >>> 16) + 0xe654) & 0xffff) << 16));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// mix in array length
|
|
29
|
+
h1 ^= bytes;
|
|
30
|
+
|
|
31
|
+
h1 ^= h1 >>> 16;
|
|
32
|
+
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16));
|
|
33
|
+
h1 ^= h1 >>> 13;
|
|
34
|
+
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16)));
|
|
35
|
+
h1 ^= h1 >>> 16;
|
|
36
|
+
|
|
37
|
+
// cast to uint32
|
|
38
|
+
return h1 >>> 0;
|
|
39
|
+
}
|
|
@@ -95,6 +95,14 @@ export class ActionProcessor {
|
|
|
95
95
|
return mark.description;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Remove all of the history
|
|
100
|
+
*/
|
|
101
|
+
clear() {
|
|
102
|
+
// drop all of the history
|
|
103
|
+
this.dropHistory(0);
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
/**
|
|
99
107
|
* Drop records beyond a given limit. records are dropped in batches between marks.
|
|
100
108
|
*
|
|
@@ -2,11 +2,11 @@ import Tool from "./engine/Tool.js";
|
|
|
2
2
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
3
3
|
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
4
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
5
|
-
import { parseHex } from "../../core/color/ColorUtils.js";
|
|
6
5
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
7
6
|
import loadSampler2D from "../../engine/graphics/texture/sampler/loadSampler2D.js";
|
|
8
7
|
import convertSampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
9
8
|
import { InstancedMeshComponent } from "../../engine/ecs/foliage/ecs/InstancedMeshComponent.js";
|
|
9
|
+
import { parseHex } from "../../core/color/parseHex.js";
|
|
10
10
|
|
|
11
11
|
class FoliagePaintTool extends Tool {
|
|
12
12
|
constructor() {
|
|
@@ -3,7 +3,6 @@ import GridPosition from "../../engine/grid/components/GridPosition.js";
|
|
|
3
3
|
import GridObstacle from "../../engine/grid/components/GridObstacle.js";
|
|
4
4
|
import { pick } from "../../../model/game/util/ScreenGridPicker.js";
|
|
5
5
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
6
|
-
import { parseHex } from "../../core/color/ColorUtils.js";
|
|
7
6
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
8
7
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
9
8
|
import WriteGridValueAction from "../actions/concrete/WriteGridValueAction.js";
|
|
@@ -12,6 +11,7 @@ import PaintTerrainOverlayAction from "../actions/concrete/PaintTerrainOverlayAc
|
|
|
12
11
|
import { decodeMouseEventButtons, PointerDevice } from "../../engine/input/devices/PointerDevice.js";
|
|
13
12
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
14
13
|
import TopDownCameraControllerSystem from "../../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
14
|
+
import { parseHex } from "../../core/color/parseHex.js";
|
|
15
15
|
|
|
16
16
|
class GridPaintTool extends Tool {
|
|
17
17
|
constructor() {
|
|
@@ -61,12 +61,29 @@ export class InstancedFoliage {
|
|
|
61
61
|
*/
|
|
62
62
|
this.instances = new InstancedMeshGroup();
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @type {THREE.BufferGeometry|null}
|
|
67
|
+
*/
|
|
64
68
|
this.geometry = null;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @type {Vector4|Vector4}
|
|
73
|
+
*/
|
|
65
74
|
this.instanceBoundingSphere = new Vector4(0, 0, 0, 0);
|
|
66
75
|
|
|
67
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @type {ThreeFrustumsIntersectionBVHVisitor}
|
|
80
|
+
*/
|
|
68
81
|
this.bvhVisibilityVisitor = new ThreeFrustumsIntersectionBVHVisitor();
|
|
69
82
|
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @type {FoliageVisibilitySetBuilder}
|
|
86
|
+
*/
|
|
70
87
|
this.visibilitySetBuilder = new FoliageVisibilitySetBuilder();
|
|
71
88
|
this.bvhVisibilityVisitor.collector = this.visibilitySetBuilder;
|
|
72
89
|
|
|
@@ -84,6 +101,10 @@ export class InstancedFoliage {
|
|
|
84
101
|
this.__garbagePointer = 0;
|
|
85
102
|
}
|
|
86
103
|
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @returns {number}
|
|
107
|
+
*/
|
|
87
108
|
hash() {
|
|
88
109
|
return this.data.hash();
|
|
89
110
|
}
|
|
@@ -95,6 +116,25 @@ export class InstancedFoliage {
|
|
|
95
116
|
|
|
96
117
|
}
|
|
97
118
|
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @param {SurfacePoint3} contact
|
|
122
|
+
* @param {number} origin_x
|
|
123
|
+
* @param {number} origin_y
|
|
124
|
+
* @param {number} origin_z
|
|
125
|
+
* @param {number} direction_x
|
|
126
|
+
* @param {number} direction_y
|
|
127
|
+
* @param {number} direction_z
|
|
128
|
+
* @returns {number} index of the contact instance, or -1 if no hit found
|
|
129
|
+
*/
|
|
130
|
+
raypick(
|
|
131
|
+
contact,
|
|
132
|
+
origin_x, origin_y, origin_z,
|
|
133
|
+
direction_x, direction_y, direction_z
|
|
134
|
+
) {
|
|
135
|
+
throw new Error('Not implemented');
|
|
136
|
+
}
|
|
137
|
+
|
|
98
138
|
dispose() {
|
|
99
139
|
this.instances.dispose();
|
|
100
140
|
}
|
|
@@ -212,6 +252,11 @@ export class InstancedFoliage {
|
|
|
212
252
|
this.instanceBoundingSphere = computeGeometryBoundingSphereMiniball(this.geometry);
|
|
213
253
|
}
|
|
214
254
|
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
* @param {BufferGeometry} geometry
|
|
258
|
+
* @param {Material} material
|
|
259
|
+
*/
|
|
215
260
|
setInstance(geometry, material) {
|
|
216
261
|
if (material === undefined) {
|
|
217
262
|
throw new Error(`Material is undefined`);
|
|
@@ -5,6 +5,48 @@ import { COMPONENT_SERIALIZATION_TRANSIENT_FIELD } from "./COMPONENT_SERIALIZATI
|
|
|
5
5
|
import { currentTimeInSeconds } from "../../Clock.js";
|
|
6
6
|
import { BinaryObjectSerializationAdapter } from "./binary/object/BinaryObjectSerializationAdapter.js";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {Class<T>|constructor|function|{serializable?:boolean}} componentClass
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
function isComponentClassSerializable(componentClass) {
|
|
14
|
+
return componentClass.serializable !== false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not an entity should be serialized at all
|
|
19
|
+
* @param {number} entity
|
|
20
|
+
* @param {EntityComponentDataset} dataset
|
|
21
|
+
* @param {number} smComponentIndex
|
|
22
|
+
* @param {Object} componentInstance
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
function isEntityTransient(entity, dataset, smComponentIndex, componentInstance) {
|
|
26
|
+
if (smComponentIndex === -1) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//check component instance flag
|
|
31
|
+
if (componentInstance[COMPONENT_SERIALIZATION_TRANSIENT_FIELD] === true) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {SerializationMetadata}
|
|
39
|
+
*/
|
|
40
|
+
const serializationMetadata = dataset.getComponentByIndex(entity, smComponentIndex);
|
|
41
|
+
|
|
42
|
+
if (serializationMetadata === undefined) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const isTransient = serializationMetadata.getFlag(SerializationFlags.Transient);
|
|
47
|
+
|
|
48
|
+
return isTransient;
|
|
49
|
+
}
|
|
8
50
|
|
|
9
51
|
class BinaryBufferSerialization {
|
|
10
52
|
constructor() {
|
|
@@ -27,9 +69,8 @@ class BinaryBufferSerialization {
|
|
|
27
69
|
|
|
28
70
|
const smComponentIndex = dataset.computeComponentTypeIndex(SerializationMetadata);
|
|
29
71
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
72
|
+
// get a list of serializable component classes
|
|
73
|
+
const serializableComponentTypes = dataset.getComponentTypeMap().filter(isComponentClassSerializable);
|
|
33
74
|
|
|
34
75
|
const numSerializableTypes = serializableComponentTypes.length;
|
|
35
76
|
|
|
@@ -59,6 +100,9 @@ class BinaryBufferSerialization {
|
|
|
59
100
|
|
|
60
101
|
const className = componentType.typeName;
|
|
61
102
|
|
|
103
|
+
if (className === undefined) {
|
|
104
|
+
throw new Error(`Component type has no .typeName property`);
|
|
105
|
+
}
|
|
62
106
|
|
|
63
107
|
collectionSerializer.setClass(className);
|
|
64
108
|
collectionSerializer.initialize({
|
|
@@ -83,7 +127,7 @@ class BinaryBufferSerialization {
|
|
|
83
127
|
return;
|
|
84
128
|
}
|
|
85
129
|
|
|
86
|
-
assert.ok(entity >= lastEntity, `entity
|
|
130
|
+
assert.ok(entity >= lastEntity, `entity[=${entity}] < lastEntity[=${lastEntity}]`);
|
|
87
131
|
|
|
88
132
|
//write only the entity step
|
|
89
133
|
const step = entity - lastEntity;
|
|
@@ -127,38 +171,4 @@ class BinaryBufferSerialization {
|
|
|
127
171
|
}
|
|
128
172
|
}
|
|
129
173
|
|
|
130
|
-
/**
|
|
131
|
-
* Whether or not an entity should be serialized at all
|
|
132
|
-
* @param {number} entity
|
|
133
|
-
* @param {EntityComponentDataset} dataset
|
|
134
|
-
* @param {number} smComponentIndex
|
|
135
|
-
* @param {Object} componentInstance
|
|
136
|
-
* @returns {boolean}
|
|
137
|
-
*/
|
|
138
|
-
function isEntityTransient(entity, dataset, smComponentIndex, componentInstance) {
|
|
139
|
-
if (smComponentIndex === -1) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
//check component instance flag
|
|
144
|
-
if (componentInstance[COMPONENT_SERIALIZATION_TRANSIENT_FIELD] === true) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
*
|
|
151
|
-
* @type {SerializationMetadata}
|
|
152
|
-
*/
|
|
153
|
-
const serializationMetadata = dataset.getComponentByIndex(entity, smComponentIndex);
|
|
154
|
-
|
|
155
|
-
if (serializationMetadata === undefined) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const isTransient = serializationMetadata.getFlag(SerializationFlags.Transient);
|
|
160
|
-
|
|
161
|
-
return isTransient;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
174
|
export default BinaryBufferSerialization;
|
|
@@ -10,8 +10,8 @@ import SVG from "../../../../../view/SVG.js";
|
|
|
10
10
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
11
11
|
import Vector4 from "../../../../../core/geom/Vector4.js";
|
|
12
12
|
import { MersenneTwister } from "../../../../../core/math/random/MersenneTwister.js";
|
|
13
|
-
import { hsv2rgb } from "../../../../../core/color/ColorUtils.js";
|
|
14
13
|
import { arrayPickBestElement } from "../../../../../core/collection/array/arrayPickBestElement.js";
|
|
14
|
+
import { hsv2rgb } from "../../../../../core/color/hsv2rgb.js";
|
|
15
15
|
|
|
16
16
|
function removeAllChildren(node) {
|
|
17
17
|
const children = node.children;
|
|
@@ -97,6 +97,9 @@ function GraphicsEngine(camera, entityManger) {
|
|
|
97
97
|
preRender: new Signal(),
|
|
98
98
|
postRender: new Signal(),
|
|
99
99
|
|
|
100
|
+
preOpaquePass: new Signal(),
|
|
101
|
+
postOpaquePass : new Signal(),
|
|
102
|
+
|
|
100
103
|
/**
|
|
101
104
|
* @deprecated
|
|
102
105
|
*/
|
|
@@ -558,6 +561,8 @@ GraphicsEngine.prototype.prepareRenderPass = function (passType) {
|
|
|
558
561
|
* Renders opaque assets
|
|
559
562
|
*/
|
|
560
563
|
GraphicsEngine.prototype.renderOpaque = function () {
|
|
564
|
+
this.on.preOpaquePass.send0();
|
|
565
|
+
|
|
561
566
|
this.prepareRenderPass(RenderPassType.Opaque);
|
|
562
567
|
|
|
563
568
|
const renderer = this.renderer;
|
|
@@ -570,6 +575,8 @@ GraphicsEngine.prototype.renderOpaque = function () {
|
|
|
570
575
|
const frameBuffer = buffers.getById(StandardFrameBuffers.ColorAndDepth);
|
|
571
576
|
|
|
572
577
|
renderTextureToScreenQuad(frameBuffer.renderTarget.texture, renderer);
|
|
578
|
+
|
|
579
|
+
this.on.postOpaquePass.send0();
|
|
573
580
|
};
|
|
574
581
|
|
|
575
582
|
/**
|
|
@@ -167,3 +167,16 @@ export class ShadedGeometry {
|
|
|
167
167
|
this.updateTransform();
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @readonly
|
|
173
|
+
* @type {string}
|
|
174
|
+
*/
|
|
175
|
+
ShadedGeometry.typeName = 'ShadedGeometry';
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* TODO add serialization support
|
|
179
|
+
* @readonly
|
|
180
|
+
* @type {boolean}
|
|
181
|
+
*/
|
|
182
|
+
ShadedGeometry.serializable = false;
|