@woosh/meep-engine 2.134.4 → 2.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/tools/v2/TransformControlsGizmo.js +1 -1
- package/editor/view/node-graph/NodeGraphEditorView.js +2 -2
- package/package.json +1 -1
- package/src/core/assert.d.ts +0 -2
- package/src/core/assert.d.ts.map +1 -1
- package/src/core/assert.js +0 -6
- package/src/core/color/Color.d.ts +0 -5
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +1 -7
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +386 -386
- package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +1 -1
- package/src/core/geom/2d/quad-tree-binary/QuadTree.js +714 -714
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +160 -160
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +96 -96
- package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +1 -1
- package/src/core/geom/packing/max-rect/findBestContainer.js +4 -4
- package/src/core/geom/packing/max-rect/packOneBox.js +2 -2
- package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.d.ts +23 -0
- package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.js +96 -0
- package/src/core/graph/layout/box/BoxLayouter.js +7 -7
- package/src/core/graph/layout/box/position_box_next_to_box.js +6 -6
- package/src/core/math/computeWholeDivisorLow.js +33 -33
- package/src/core/math/linalg/eigen/eigen_values_find_spectral_gap.d.ts.map +1 -0
- package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts +10 -0
- package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts.map +1 -0
- package/src/core/{graph → math/linalg}/eigen/matrix_eigenvalues_in_place.js +8 -7
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts.map +1 -0
- package/src/core/{graph → math/linalg}/eigen/matrix_householder_in_place.js +11 -5
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +15 -0
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -0
- package/src/core/{graph → math/linalg}/eigen/matrix_qr_in_place.js +8 -2
- package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.d.ts +17 -0
- package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.d.ts.map +1 -0
- package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.js +107 -0
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts +19 -0
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +161 -0
- package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts +15 -0
- package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_real_roots_in_interval.js +200 -0
- package/src/core/math/solveCubic.d.ts +15 -0
- package/src/core/math/solveCubic.d.ts.map +1 -0
- package/src/core/math/solveCubic.js +82 -0
- package/src/core/math/spline/spline3_hermite_bounds_t.d.ts +23 -0
- package/src/core/math/spline/spline3_hermite_bounds_t.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_bounds_t.js +109 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts +25 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.js +44 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts +16 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +120 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +11 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +451 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts +12 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.js +339 -0
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts +15 -0
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +21 -0
- package/src/core/math/spline/spline3_hermite_to_monomial.d.ts +24 -0
- package/src/core/math/spline/spline3_hermite_to_monomial.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_to_monomial.js +37 -0
- package/src/core/math/spline/v3_computeCatmullRomSplineUniformDistance.js +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
- package/src/core/model/reactive/model/util/createRandomReactiveExpression.js +185 -185
- package/src/core/process/delay.js +16 -16
- package/src/engine/animation/async/TimeSeries.js +300 -300
- package/src/engine/animation/curve/AnimationCurve.d.ts +3 -2
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +3 -2
- package/src/engine/animation/curve/draw/position_canvas_to_curve.js +2 -2
- package/src/engine/animation/curve/draw/position_curve_to_canvas.js +2 -2
- package/src/engine/ecs/fow/shader/FogOfWarRenderer.js +145 -145
- package/src/engine/ecs/gui/position/ViewportPositionSystem.js +2 -2
- package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
- package/src/engine/ecs/transform/Transform.d.ts +0 -10
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +0 -12
- package/src/engine/graphics/composit/CompositLayer.js +254 -254
- package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +1 -1
- package/src/engine/graphics/ecs/path/tube/build/build_geometry_linear.js +2 -2
- package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +3 -3
- package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +201 -201
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +2 -2
- package/src/engine/graphics/render/forward_plus/LightManager.js +1226 -1226
- package/src/engine/graphics/render/forward_plus/model/PointLight.js +1 -1
- package/src/engine/graphics/sh3/lpv/lpv_obtain_storage_cached_volume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
- package/src/engine/graphics/texture/atlas/TextureAtlasDebugger.js +1 -1
- package/src/engine/graphics/texture/sampler/HarmonicDiffusionGrid.js +145 -145
- package/src/engine/graphics/texture/sampler/serialization/TextureBinaryBufferSerializer.js +2 -2
- package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts +2 -6
- package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/BehaviorComponent.js +0 -10
- package/src/engine/intelligence/mcts/MonteCarlo.js +275 -275
- package/src/engine/navigation/ecs/path_following/PathFollower.js +222 -222
- package/src/generation/grid/GridData.js +220 -220
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +385 -385
- package/src/view/elements/image/SvgImageView.js +1 -1
- package/src/view/elements/windrose/WindRoseDiagram.js +369 -369
- package/src/view/minimap/gl/MinimapFogOfWar.js +3 -3
- package/src/view/util/DomSizeObserver.js +1 -1
- package/src/core/binary/clz32.d.ts +0 -6
- package/src/core/binary/clz32.d.ts.map +0 -1
- package/src/core/binary/clz32.js +0 -5
- package/src/core/binary/type/dataTypeFromTypedArray.d.ts +0 -8
- package/src/core/binary/type/dataTypeFromTypedArray.d.ts.map +0 -1
- package/src/core/binary/type/dataTypeFromTypedArray.js +0 -11
- package/src/core/collection/array/computeHashIntegerArray.d.ts +0 -1
- package/src/core/collection/array/computeHashIntegerArray.d.ts.map +0 -1
- package/src/core/collection/array/computeHashIntegerArray.js +0 -7
- package/src/core/collection/array/typed/typedArrayToDataType.d.ts +0 -6
- package/src/core/collection/array/typed/typedArrayToDataType.d.ts.map +0 -1
- package/src/core/collection/array/typed/typedArrayToDataType.js +0 -6
- package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.d.ts +0 -6
- package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.d.ts.map +0 -1
- package/src/core/geom/3d/mat4/MATRIX_4_IDENTITY.js +0 -7
- package/src/core/graph/eigen/eigen_values_find_spectral_gap.d.ts.map +0 -1
- package/src/core/graph/eigen/matrix_eigenvalues_in_place.d.ts +0 -8
- package/src/core/graph/eigen/matrix_eigenvalues_in_place.d.ts.map +0 -1
- package/src/core/graph/eigen/matrix_householder_in_place.d.ts.map +0 -1
- package/src/core/graph/eigen/matrix_qr_in_place.d.ts +0 -9
- package/src/core/graph/eigen/matrix_qr_in_place.d.ts.map +0 -1
- package/src/core/math/spline/cubicCurve.d.ts +0 -6
- package/src/core/math/spline/cubicCurve.d.ts.map +0 -1
- package/src/core/math/spline/cubicCurve.js +0 -6
- package/src/core/math/spline/spline_bezier2.d.ts +0 -6
- package/src/core/math/spline/spline_bezier2.d.ts.map +0 -1
- package/src/core/math/spline/spline_bezier2.js +0 -6
- package/src/core/math/spline/spline_bezier3.d.ts +0 -6
- package/src/core/math/spline/spline_bezier3.d.ts.map +0 -1
- package/src/core/math/spline/spline_bezier3.js +0 -6
- package/src/core/math/spline/spline_bezier3_bounds.d.ts +0 -6
- package/src/core/math/spline/spline_bezier3_bounds.d.ts.map +0 -1
- package/src/core/math/spline/spline_bezier3_bounds.js +0 -6
- package/src/core/math/spline/spline_hermite3.d.ts +0 -6
- package/src/core/math/spline/spline_hermite3.d.ts.map +0 -1
- package/src/core/math/spline/spline_hermite3.js +0 -6
- package/src/core/math/spline/spline_hermite3_bounds.d.ts +0 -6
- package/src/core/math/spline/spline_hermite3_bounds.d.ts.map +0 -1
- package/src/core/math/spline/spline_hermite3_bounds.js +0 -6
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +0 -2
- package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +0 -1
- package/src/core/math/spline/spline_hermite3_to_bezier.js +0 -6
- package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.d.ts +0 -37
- package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.d.ts.map +0 -1
- package/src/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.js +0 -70
- /package/src/core/{graph → math/linalg}/eigen/eigen_values_find_spectral_gap.d.ts +0 -0
- /package/src/core/{graph → math/linalg}/eigen/eigen_values_find_spectral_gap.js +0 -0
- /package/src/core/{graph → math/linalg}/eigen/matrix_householder_in_place.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { vec3 } from "gl-matrix";
|
|
2
|
-
import {
|
|
2
|
+
import { compute_binary_data_type_from_typed_array } from "../../../../../core/collection/array/typed/compute_binary_data_type_from_typed_array.js";
|
|
3
3
|
import { v3_array_matrix4_rotate } from "../../../../../core/geom/vec3/v3_array_matrix4_rotate.js";
|
|
4
4
|
import { v3_distance_sqr } from "../../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
5
5
|
import { decode_attribute_value } from "../../../geometry/decode_attribute_value.js";
|
|
@@ -32,7 +32,7 @@ function sample_color_attribute(
|
|
|
32
32
|
const color_array = color_attribute.array;
|
|
33
33
|
sample_triangle_attribute(color, 0, index_0, index_1, index_2, color_array, color_attribute.itemSize, u, v);
|
|
34
34
|
|
|
35
|
-
const type =
|
|
35
|
+
const type = compute_binary_data_type_from_typed_array(color_array);
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i < 3; i++) {
|
|
38
38
|
color[i] = decode_attribute_value(
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { assert } from "../../../../core/assert.js";
|
|
2
|
-
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
3
|
-
|
|
4
|
-
export class HarmonicDiffusionGrid {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {number[]|Float32Array|Float64Array} data
|
|
8
|
-
* @param {number} width
|
|
9
|
-
* @param {number} height
|
|
10
|
-
*/
|
|
11
|
-
constructor(data, width, height) {
|
|
12
|
-
assert.isNonNegativeInteger(width, 'width');
|
|
13
|
-
assert.isNonNegativeInteger(height, 'height');
|
|
14
|
-
|
|
15
|
-
assert.equal(data.length, width * height, `data.length(=${data.length}) is not equal to product of width(=${width})*height(=${height})`);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @type {number[]|Float32Array|Float64Array}
|
|
20
|
-
*/
|
|
21
|
-
this.data = data;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {number}
|
|
25
|
-
*/
|
|
26
|
-
this.width = width;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @type {number}
|
|
30
|
-
*/
|
|
31
|
-
this.height = height;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Maps which indices are assigned with values. Assigned cells retain their original values
|
|
35
|
-
* @type {BitSet}
|
|
36
|
-
*/
|
|
37
|
-
this.assignment = new BitSet();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Clear all assignments
|
|
42
|
-
*/
|
|
43
|
-
reset() {
|
|
44
|
-
//clear assigned values
|
|
45
|
-
this.assignment.reset();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {number} x
|
|
51
|
-
* @param {number} y
|
|
52
|
-
* @param {number} value
|
|
53
|
-
*/
|
|
54
|
-
assign(x, y, value) {
|
|
55
|
-
|
|
56
|
-
assert.isNumber(x, 'x');
|
|
57
|
-
assert.isNumber(y, 'y');
|
|
58
|
-
assert.isNumber(value, 'value');
|
|
59
|
-
|
|
60
|
-
assert.ok(x >= 0, `x(=${x}) is less than 0`);
|
|
61
|
-
assert.ok(x < this.width, `x(=${x}) >= width(=${this.width})`);
|
|
62
|
-
|
|
63
|
-
assert.ok(y >= 0, `y(=${y}) is less than 0`);
|
|
64
|
-
assert.ok(y < this.height, `y(=${y}) >= height(=${this.height})`);
|
|
65
|
-
|
|
66
|
-
assert.
|
|
67
|
-
assert.notNaN(value, 'value');
|
|
68
|
-
|
|
69
|
-
//compute index
|
|
70
|
-
const index = y * this.width + x;
|
|
71
|
-
|
|
72
|
-
//set assignment flag
|
|
73
|
-
this.assignment.set(index, true);
|
|
74
|
-
|
|
75
|
-
//write value
|
|
76
|
-
this.data[index] = value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Diffuses assigned values across the grid, to achieve good diffusion large number of steps might be necessary
|
|
81
|
-
*/
|
|
82
|
-
step() {
|
|
83
|
-
//iterate over all unassigned elements
|
|
84
|
-
const width = this.width;
|
|
85
|
-
const indexLimit = this.height * width;
|
|
86
|
-
|
|
87
|
-
const assignment = this.assignment;
|
|
88
|
-
|
|
89
|
-
const data = this.data;
|
|
90
|
-
|
|
91
|
-
let i;
|
|
92
|
-
|
|
93
|
-
let sum;
|
|
94
|
-
let neighbourCount;
|
|
95
|
-
|
|
96
|
-
const lastRowIndex = width - 1;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for (i = 0; i < indexLimit; i++) {
|
|
100
|
-
|
|
101
|
-
if (assignment.get(i)) {
|
|
102
|
-
//cell is assigned, skip
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
neighbourCount = 0;
|
|
107
|
-
sum = 0;
|
|
108
|
-
|
|
109
|
-
const indexTop = i - width;
|
|
110
|
-
|
|
111
|
-
if (indexTop >= 0) {
|
|
112
|
-
//top is within bounds
|
|
113
|
-
sum += data[indexTop];
|
|
114
|
-
neighbourCount++;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (i % width > 0) {
|
|
118
|
-
//left is within bounds
|
|
119
|
-
sum += data[i - 1];
|
|
120
|
-
neighbourCount++;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (i % width !== lastRowIndex) {
|
|
124
|
-
//right is within bounds
|
|
125
|
-
sum += data[i + 1];
|
|
126
|
-
neighbourCount++;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const indexBottom = i + width;
|
|
130
|
-
|
|
131
|
-
if (indexBottom < indexLimit) {
|
|
132
|
-
sum += data[indexBottom];
|
|
133
|
-
neighbourCount++;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//compute diffuse value
|
|
137
|
-
const value = sum / neighbourCount;
|
|
138
|
-
|
|
139
|
-
//write value
|
|
140
|
-
data[i] = value;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
}
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
3
|
+
|
|
4
|
+
export class HarmonicDiffusionGrid {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number[]|Float32Array|Float64Array} data
|
|
8
|
+
* @param {number} width
|
|
9
|
+
* @param {number} height
|
|
10
|
+
*/
|
|
11
|
+
constructor(data, width, height) {
|
|
12
|
+
assert.isNonNegativeInteger(width, 'width');
|
|
13
|
+
assert.isNonNegativeInteger(height, 'height');
|
|
14
|
+
|
|
15
|
+
assert.equal(data.length, width * height, `data.length(=${data.length}) is not equal to product of width(=${width})*height(=${height})`);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {number[]|Float32Array|Float64Array}
|
|
20
|
+
*/
|
|
21
|
+
this.data = data;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
this.width = width;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
this.height = height;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Maps which indices are assigned with values. Assigned cells retain their original values
|
|
35
|
+
* @type {BitSet}
|
|
36
|
+
*/
|
|
37
|
+
this.assignment = new BitSet();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Clear all assignments
|
|
42
|
+
*/
|
|
43
|
+
reset() {
|
|
44
|
+
//clear assigned values
|
|
45
|
+
this.assignment.reset();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {number} x
|
|
51
|
+
* @param {number} y
|
|
52
|
+
* @param {number} value
|
|
53
|
+
*/
|
|
54
|
+
assign(x, y, value) {
|
|
55
|
+
|
|
56
|
+
assert.isNumber(x, 'x');
|
|
57
|
+
assert.isNumber(y, 'y');
|
|
58
|
+
assert.isNumber(value, 'value');
|
|
59
|
+
|
|
60
|
+
assert.ok(x >= 0, `x(=${x}) is less than 0`);
|
|
61
|
+
assert.ok(x < this.width, `x(=${x}) >= width(=${this.width})`);
|
|
62
|
+
|
|
63
|
+
assert.ok(y >= 0, `y(=${y}) is less than 0`);
|
|
64
|
+
assert.ok(y < this.height, `y(=${y}) >= height(=${this.height})`);
|
|
65
|
+
|
|
66
|
+
assert.isFinite(value, 'values');
|
|
67
|
+
assert.notNaN(value, 'value');
|
|
68
|
+
|
|
69
|
+
//compute index
|
|
70
|
+
const index = y * this.width + x;
|
|
71
|
+
|
|
72
|
+
//set assignment flag
|
|
73
|
+
this.assignment.set(index, true);
|
|
74
|
+
|
|
75
|
+
//write value
|
|
76
|
+
this.data[index] = value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Diffuses assigned values across the grid, to achieve good diffusion large number of steps might be necessary
|
|
81
|
+
*/
|
|
82
|
+
step() {
|
|
83
|
+
//iterate over all unassigned elements
|
|
84
|
+
const width = this.width;
|
|
85
|
+
const indexLimit = this.height * width;
|
|
86
|
+
|
|
87
|
+
const assignment = this.assignment;
|
|
88
|
+
|
|
89
|
+
const data = this.data;
|
|
90
|
+
|
|
91
|
+
let i;
|
|
92
|
+
|
|
93
|
+
let sum;
|
|
94
|
+
let neighbourCount;
|
|
95
|
+
|
|
96
|
+
const lastRowIndex = width - 1;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
for (i = 0; i < indexLimit; i++) {
|
|
100
|
+
|
|
101
|
+
if (assignment.get(i)) {
|
|
102
|
+
//cell is assigned, skip
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
neighbourCount = 0;
|
|
107
|
+
sum = 0;
|
|
108
|
+
|
|
109
|
+
const indexTop = i - width;
|
|
110
|
+
|
|
111
|
+
if (indexTop >= 0) {
|
|
112
|
+
//top is within bounds
|
|
113
|
+
sum += data[indexTop];
|
|
114
|
+
neighbourCount++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (i % width > 0) {
|
|
118
|
+
//left is within bounds
|
|
119
|
+
sum += data[i - 1];
|
|
120
|
+
neighbourCount++;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (i % width !== lastRowIndex) {
|
|
124
|
+
//right is within bounds
|
|
125
|
+
sum += data[i + 1];
|
|
126
|
+
neighbourCount++;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const indexBottom = i + width;
|
|
130
|
+
|
|
131
|
+
if (indexBottom < indexLimit) {
|
|
132
|
+
sum += data[indexBottom];
|
|
133
|
+
neighbourCount++;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//compute diffuse value
|
|
137
|
+
const value = sum / neighbourCount;
|
|
138
|
+
|
|
139
|
+
//write value
|
|
140
|
+
data[i] = value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -2,7 +2,7 @@ import { assert } from "../../../../../core/assert.js";
|
|
|
2
2
|
import { EndianType } from "../../../../../core/binary/EndianType.js";
|
|
3
3
|
import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
|
|
4
4
|
import { DataTypeByteSizes } from "../../../../../core/binary/type/DataTypeByteSizes.js";
|
|
5
|
-
import {
|
|
5
|
+
import { compute_binary_data_type_from_typed_array } from "../../../../../core/collection/array/typed/compute_binary_data_type_from_typed_array.js";
|
|
6
6
|
import { DataTypeIndices } from "../../../../../core/binary/type/DataTypeIndices.js";
|
|
7
7
|
import { Sampler2D } from "../Sampler2D.js";
|
|
8
8
|
|
|
@@ -95,7 +95,7 @@ export function serializeTexture(buffer, texture) {
|
|
|
95
95
|
buffer.writeUint32(height);
|
|
96
96
|
buffer.writeUint8(itemSize); //number of channels
|
|
97
97
|
|
|
98
|
-
const type =
|
|
98
|
+
const type = compute_binary_data_type_from_typed_array(texture.data);
|
|
99
99
|
buffer.writeUint8(DataTypeIndices[type]);
|
|
100
100
|
const array = texture.data;
|
|
101
101
|
|
|
@@ -83,12 +83,8 @@ export class BehaviorComponent {
|
|
|
83
83
|
get behavior(): any;
|
|
84
84
|
}
|
|
85
85
|
export namespace BehaviorComponent {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
import looping_function = BehaviorComponent.loop;
|
|
89
|
-
export { looping_function };
|
|
90
|
-
export let serializable: boolean;
|
|
91
|
-
export let typeName: string;
|
|
86
|
+
let serializable: boolean;
|
|
87
|
+
let typeName: string;
|
|
92
88
|
}
|
|
93
89
|
import { ClockChannelType } from "./ClockChannelType.js";
|
|
94
90
|
//# sourceMappingURL=BehaviorComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BehaviorComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponent.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH;IA8EI;;;;;;OAMG;IACH,yCAFa,iBAAiB,CAQ7B;IAED;;;;OAIG;IACH,0BAFa,iBAAiB,CAa7B;IA3GD;;;;OAIG;IACH,OAFU,gBAAgB,GAAC,MAAM,CAEG;IAEpC;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,mBAAkB;IAElB;;;;OAIG;IACH,cAHW,MAAM,wBAAsB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,wBAAsB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,wBAAsB,SAC5B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,wBAAsB,GAC1B,OAAO,CAInB;IAUD;;;OAGG;IACH,uBAEC;IAdD;;;OAGG;IACH,oBAEC;CA0CJ
|
|
1
|
+
{"version":3,"file":"BehaviorComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponent.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH;IA8EI;;;;;;OAMG;IACH,yCAFa,iBAAiB,CAQ7B;IAED;;;;OAIG;IACH,0BAFa,iBAAiB,CAa7B;IA3GD;;;;OAIG;IACH,OAFU,gBAAgB,GAAC,MAAM,CAEG;IAEpC;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,mBAAkB;IAElB;;;;OAIG;IACH,cAHW,MAAM,wBAAsB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,wBAAsB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,wBAAsB,SAC5B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,wBAAsB,GAC1B,OAAO,CAInB;IAUD;;;OAGG;IACH,uBAEC;IAdD;;;OAGG;IACH,oBAEC;CA0CJ;;sBAIS,OAAO;kBAMP,MAAM;;iCA3IiB,uBAAuB"}
|
|
@@ -132,16 +132,6 @@ export class BehaviorComponent {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* @deprecated use {@link BehaviorComponent.from} instead
|
|
137
|
-
*/
|
|
138
|
-
BehaviorComponent.fromOne = BehaviorComponent.from;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated use {@link BehaviorComponent.loop} instead
|
|
142
|
-
*/
|
|
143
|
-
BehaviorComponent.looping_function = BehaviorComponent.loop;
|
|
144
|
-
|
|
145
135
|
/**
|
|
146
136
|
* @readonly
|
|
147
137
|
* @type {boolean}
|