@woosh/meep-engine 2.37.17 → 2.37.20
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/assert.js +1 -1
- package/core/binary/float2uint8.js +8 -0
- package/core/binary/uint82float.js +8 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +6 -4
- package/core/collection/array/typed/isTypedArray.js +20 -0
- package/core/collection/array/typedArrayToDataType.js +1 -0
- package/core/collection/list/List.d.ts +1 -1
- package/core/collection/table/RowFirstTable.js +34 -0
- package/core/collection/table/RowFirstTable.spec.js +59 -1
- package/core/color/Color.js +83 -1
- package/core/color/YCbCr_to_rgb_uint24.js +3 -4
- package/core/color/hsv2rgb.js +4 -3
- package/core/color/linear_to_sRGB.js +4 -5
- package/core/color/rgb2hex.js +1 -1
- package/core/color/rgb2uint24.js +6 -4
- package/core/color/rgb_to_YCbCr_uint24.js +11 -13
- package/core/events/signal/Signal.d.ts +11 -9
- package/core/events/signal/Signal.js +8 -8
- package/core/events/signal/Signal.spec.js +16 -0
- package/core/geom/2d/quad-tree/qt_collect_by_circle.js +67 -0
- package/core/geom/Quaternion.d.ts +21 -1
- package/core/geom/Quaternion.js +279 -200
- package/core/geom/Quaternion.spec.js +71 -2
- package/core/geom/Vector2.js +3 -3
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +31 -7
- package/core/geom/Vector3.schema.json +16 -0
- package/core/geom/Vector4.js +16 -0
- package/core/json/JsonUtils.js +2 -20
- package/core/math/bell_membership_function.js +19 -0
- package/core/math/exp2.js +8 -0
- package/core/math/interval/NumericInterval.js +17 -0
- package/core/math/physics/brdf/brdf_burley.js +25 -0
- package/core/math/physics/bsdf/bsdf_schlick.js +22 -0
- package/core/math/physics/irradiance/interpolate_irradiance_linear.js +18 -0
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundLogarithmic.js → core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js} +2 -2
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundSmith.js → core/math/physics/irradiance/interpolate_irradiance_smith.js} +1 -1
- package/core/model/ObservedEnum.js +8 -0
- package/editor/Editor.js +97 -1
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +13 -105
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +90 -0
- package/editor/ecs/component/createObjectEditor.js +266 -60
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +50 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +107 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +44 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +54 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +89 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +56 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +32 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/tools/SelectionTool.js +1 -1
- package/editor/tools/paint/TerrainHeightPaintTool.js +88 -68
- package/editor/tools/paint/TerrainPaintTool.js +2 -1
- package/editor/tools/paint/TerrainTexturePaintTool.js +8 -73
- package/editor/view/EditorView.js +1 -1
- package/editor/view/ecs/ComponentControlView.js +2 -30
- package/editor/view/ecs/EntityEditor.js +61 -139
- package/editor/view/ecs/components/GridObstacleController.js +4 -4
- package/editor/view/ecs/components/TerrainController.js +1 -1
- package/editor/view/ecs/components/common/NumberController.js +19 -7
- package/engine/animation/keyed2/AnimationTrack.js +1 -1
- package/engine/asset/AssetManager.d.ts +1 -1
- package/engine/asset/AssetManager.js +390 -388
- package/engine/asset/loaders/gltf/extensions/MSFT_texture_dds.js +14 -2
- package/engine/ecs/components/TagEditor.js +15 -0
- package/engine/ecs/fow/FogOfWarEditor.js +13 -0
- package/engine/ecs/terrain/ecs/OffsetScaleTransform2D.d.ts +6 -0
- package/engine/ecs/terrain/ecs/Terrain.js +44 -43
- package/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +26 -28
- package/engine/ecs/terrain/overlay/TerrainOverlay.js +71 -66
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +23 -0
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +1 -1
- package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +13 -7
- package/engine/ecs/transform/Transform.d.ts +2 -0
- package/engine/ecs/transform/Transform.editor.schema.json +16 -0
- package/engine/ecs/transform/Transform.js +3 -0
- package/engine/graphics/ecs/highlight/HighlightEditor.js +17 -0
- package/engine/graphics/ecs/light/Light.js +0 -47
- package/engine/graphics/ecs/light/LightSerializationAdapter.js +50 -0
- package/engine/graphics/ecs/mesh/MeshEditor.js +28 -0
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +2 -1
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +3 -1
- package/engine/graphics/ecs/sprite/Sprite.js +11 -0
- package/engine/graphics/ecs/sprite/SpriteSystemPE.js +133 -0
- package/engine/graphics/ecs/sprite/prototypeSpriteSystem.js +1566 -0
- package/engine/graphics/micron/prototypeVirtualGeometry.js +2 -2
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +15 -15
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +17 -9
- package/engine/graphics/particles/particular/engine/renderers/ParticleRenderer.js +12 -10
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +7 -2
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticlePool.js +27 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticleRenderer.js +80 -0
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +16 -4
- package/engine/graphics/shaders/TerrainShader.js +8 -8
- package/engine/graphics/texture/atlas/TextureAtlasDebugger.js +2 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +206 -201
- package/engine/graphics/texture/sampler/Sampler2D.spec.js +34 -35
- package/engine/graphics/texture/sampler/bicubic.js +59 -0
- package/engine/graphics/texture/sampler/downsampleSample2D.spec.js +2 -2
- package/engine/graphics/texture/sampler/genericResampleSampler2D.js +0 -2
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +146 -0
- package/engine/graphics/texture/sampler/{downsampleSampler2D.js → sampler2D_scale_down_linear.js} +8 -4
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +140 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +3 -3
- package/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +1 -1
- package/engine/graphics/util/ScaleObject3ToBox.js +14 -1
- package/engine/graphics/util/makeMeshPreviewScene.js +2 -1
- package/engine/grid/components/GridObstacle.js +0 -44
- package/engine/grid/components/GridObstacleSerializationAdapter.js +46 -0
- package/engine/input/ecs/util/TerrainCameraTargetSampler.js +2 -2
- package/engine/navigation/ecs/components/Path.d.ts +2 -0
- package/engine/navigation/ecs/components/Path.js +6 -1
- package/engine/navigation/ecs/components/computeNonuniformCatmullRomSplineSample.js +117 -0
- package/engine/platform/GetURLHash.js +27 -0
- package/engine/platform/WebEnginePlatform.js +1 -22
- package/engine/sound/ecs/emitter/SoundEmitter.js +10 -6
- package/generation/GridGenerator.js +7 -6
- package/generation/example/SampleGenerator0.js +39 -35
- package/generation/example/filters/SampleGroundMoistureFilter.js +58 -17
- package/generation/example/generators/interactive/mir_generator_place_buff_objects.js +7 -6
- package/generation/example/generators/mir_generator_place_bases.js +7 -3
- package/generation/example/generators/mir_generator_place_road_decorators.js +3 -3
- package/generation/example/generators/mir_generator_place_starting_point.js +3 -2
- package/generation/example/themes/SampleTheme0.js +11 -7
- package/generation/filtering/numeric/CellFilterLiteralFloat.js +5 -0
- package/generation/filtering/numeric/complex/CellFilterDilate.js +36 -0
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +15 -5
- package/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +53 -1
- package/generation/filtering/numeric/math/CellFilterMax2.js +3 -0
- package/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +55 -0
- package/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +42 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +36 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +41 -0
- package/generation/grid/GridData.d.ts +5 -1
- package/generation/grid/GridData.js +35 -36
- package/generation/grid/MarkerMatchCounter.js +5 -3
- package/generation/markers/GridActionRuleSet.js +15 -32
- package/generation/markers/GridCellActionPlaceMarker.js +12 -8
- package/generation/markers/debug/visualizeMarkers.js +56 -36
- package/generation/markers/emitter/MarkerNodeEmitterFromAction.js +8 -8
- package/generation/markers/prototypeGridCellActionPlaceMarker.js +209 -0
- package/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -5
- package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +2 -2
- package/generation/placement/GridCellPlacementRule.js +31 -25
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/from_image.js +7 -3
- package/samples/terrain/main.js +1 -1
- package/view/View.js +23 -1
- package/view/common/LabelView.js +1 -1
- package/view/compose3x3transform.js +32 -8
- package/view/controller/dat/DatGuiUtils.js +1 -1
- package/view/elements/DropDownSelectionView.js +11 -3
- package/view/elements/image/ImageView.js +3 -1
- package/core/model/ObservedReal.js +0 -55
- package/editor/ecs/component/ObjectEditor.js +0 -0
- package/engine/graphics/particles/particular/engine/renderers/SoftBillboardParticleRenderer.js +0 -7
- package/engine/sound/ecs/emitter/attenuate/attenuateSoundLinear.js +0 -11
- package/generation/filtering/numeric/CellFilterReadGridLayer.js +0 -73
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../core/assert.js";
|
|
2
2
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
3
3
|
import { CellFilterLiteralFloat } from "../filtering/numeric/CellFilterLiteralFloat.js";
|
|
4
|
+
import { GridCellActionSequence } from "./action/util/GridCellActionSequence.js";
|
|
4
5
|
|
|
5
6
|
export class GridCellPlacementRule {
|
|
6
7
|
constructor() {
|
|
@@ -25,9 +26,9 @@ export class GridCellPlacementRule {
|
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
*
|
|
28
|
-
* @type {GridCellAction
|
|
29
|
+
* @type {GridCellAction}
|
|
29
30
|
*/
|
|
30
|
-
this.
|
|
31
|
+
this.action = null;
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
*
|
|
@@ -39,28 +40,44 @@ export class GridCellPlacementRule {
|
|
|
39
40
|
/**
|
|
40
41
|
*
|
|
41
42
|
* @param {CellMatcher} matcher
|
|
42
|
-
* @param {GridCellAction[]} actions
|
|
43
|
+
* @param {GridCellAction[]} [actions]
|
|
44
|
+
* @param {GridCellAction} action
|
|
43
45
|
* @param {number|CellFilter} [probability]
|
|
44
46
|
* @param {Vector2} [offset]
|
|
47
|
+
* @param {boolean} [allowRotation]
|
|
45
48
|
* @returns {GridCellPlacementRule}
|
|
46
49
|
*/
|
|
47
|
-
static from({
|
|
50
|
+
static from({
|
|
51
|
+
matcher,
|
|
52
|
+
actions,
|
|
53
|
+
action = GridCellActionSequence.from(actions),
|
|
54
|
+
probability = CellFilterLiteralFloat.from(1),
|
|
55
|
+
offset = Vector2.zero,
|
|
56
|
+
allowRotation = true
|
|
57
|
+
}) {
|
|
48
58
|
|
|
49
59
|
assert.defined(matcher);
|
|
50
|
-
assert.defined(
|
|
51
|
-
|
|
52
|
-
assert.isArray(actions);
|
|
60
|
+
assert.defined(action);
|
|
53
61
|
|
|
54
62
|
const r = new GridCellPlacementRule();
|
|
55
63
|
|
|
56
64
|
r.pattern = matcher;
|
|
57
|
-
|
|
65
|
+
|
|
66
|
+
r.action = action;
|
|
67
|
+
|
|
68
|
+
if (actions !== undefined) {
|
|
69
|
+
console.warn(`"actions" parameter is deprecated. Use a sequence instead`);
|
|
70
|
+
assert.isArray(actions, 'actions');
|
|
71
|
+
}
|
|
58
72
|
|
|
59
73
|
assert.equal(probability.isCellFilter, true, 'probability.isCellFilter !== true');
|
|
74
|
+
|
|
60
75
|
r.probability = probability;
|
|
61
76
|
|
|
62
77
|
r.positionOffset.copy(offset);
|
|
63
78
|
|
|
79
|
+
r.allowRotation = allowRotation;
|
|
80
|
+
|
|
64
81
|
return r;
|
|
65
82
|
}
|
|
66
83
|
|
|
@@ -70,14 +87,8 @@ export class GridCellPlacementRule {
|
|
|
70
87
|
* @param {number} seed
|
|
71
88
|
*/
|
|
72
89
|
initialize(grid, seed) {
|
|
73
|
-
const actions = this.actions;
|
|
74
|
-
const n = actions.length;
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
const action = actions[i];
|
|
78
|
-
|
|
79
|
-
action.initialize(grid, seed);
|
|
80
|
-
}
|
|
91
|
+
this.action.initialize(grid, seed);
|
|
81
92
|
|
|
82
93
|
this.pattern.initialize(grid, seed);
|
|
83
94
|
|
|
@@ -94,23 +105,18 @@ export class GridCellPlacementRule {
|
|
|
94
105
|
* @param {number} rotation in Radians
|
|
95
106
|
*/
|
|
96
107
|
execute(grid, x, y, rotation) {
|
|
97
|
-
const actions = this.actions;
|
|
98
|
-
const n = actions.length;
|
|
99
|
-
|
|
100
108
|
const sin = Math.sin(rotation);
|
|
101
109
|
const cos = Math.cos(rotation);
|
|
102
110
|
|
|
103
|
-
const
|
|
104
|
-
|
|
111
|
+
const offset = this.positionOffset;
|
|
112
|
+
|
|
113
|
+
const local_x = offset.x;
|
|
114
|
+
const local_y = offset.y;
|
|
105
115
|
|
|
106
116
|
const rotated_local_x = local_x * cos - local_y * sin
|
|
107
117
|
const rotated_local_y = local_x * sin + local_y * cos;
|
|
108
118
|
|
|
109
|
-
|
|
110
|
-
const action = actions[i];
|
|
111
|
-
|
|
112
|
-
action.execute(grid, x + rotated_local_x, y + rotated_local_y, rotation);
|
|
113
|
-
}
|
|
119
|
+
this.action.execute(grid, x + rotated_local_x, y + rotated_local_y, rotation);
|
|
114
120
|
|
|
115
121
|
}
|
|
116
122
|
}
|
|
@@ -573,7 +573,7 @@ export class ThemeEngine {
|
|
|
573
573
|
const tTerrainGeometry = futureTask(new Future((resolve, reject) => {
|
|
574
574
|
|
|
575
575
|
terrain.updateWorkerHeights();
|
|
576
|
-
terrain.
|
|
576
|
+
terrain.__tiles.rebuild();
|
|
577
577
|
|
|
578
578
|
terrain.promiseAllTiles().then(resolve, reject);
|
|
579
579
|
}), 'Wait for terrain tiles');
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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.37.
|
|
8
|
+
"version": "2.37.20",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -19,14 +19,18 @@ import { TerrainLayerDescription } from "../../generation/theme/TerrainLayerDesc
|
|
|
19
19
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
20
20
|
import { CellFilterLiteralFloat } from "../../generation/filtering/numeric/CellFilterLiteralFloat.js";
|
|
21
21
|
import { GridDataLayer } from "../../generation/grid/layers/GridDataLayer.js";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
CellFilterSampleLayerLinear
|
|
24
|
+
} from "../../generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js";
|
|
23
25
|
import { CellFilterSmoothStep } from "../../generation/filtering/numeric/math/CellFilterSmoothStep.js";
|
|
24
26
|
import { CellFilterOneMinus } from "../../generation/filtering/numeric/math/CellFilterOneMinus.js";
|
|
25
27
|
import { CellFilterMultiply } from "../../generation/filtering/numeric/math/algebra/CellFilterMultiply.js";
|
|
26
28
|
import { CellFilterCurvature } from "../../generation/filtering/numeric/complex/CellFilterCurvature.js";
|
|
27
29
|
import { CellFilterMax2 } from "../../generation/filtering/numeric/math/CellFilterMax2.js";
|
|
28
30
|
import { CellFilterMin2 } from "../../generation/filtering/numeric/math/CellFilterMin2.js";
|
|
29
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
AmbientOcclusionPostProcessEffect
|
|
33
|
+
} from "../../engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
30
34
|
import { CellFilterAngleToNormal } from "../../generation/filtering/numeric/complex/CellFilterAngleToNormal.js";
|
|
31
35
|
import { CellFilterCache } from "../../generation/filtering/numeric/CellFilterCache.js";
|
|
32
36
|
|
|
@@ -61,7 +65,7 @@ function makeTheme() {
|
|
|
61
65
|
|
|
62
66
|
const terrainTheme = new TerrainTheme();
|
|
63
67
|
|
|
64
|
-
const height =
|
|
68
|
+
const height = CellFilterSampleLayerLinear.from('height');
|
|
65
69
|
const curvature = CellFilterCurvature.from(height);
|
|
66
70
|
|
|
67
71
|
const slope = CellFilterAngleToNormal.from(height, Vector3.forward);
|
package/samples/terrain/main.js
CHANGED
package/view/View.js
CHANGED
|
@@ -26,7 +26,7 @@ function setElementTransform(domElement, position, scale, rotation) {
|
|
|
26
26
|
|
|
27
27
|
const m3 = scratch_m3_0;
|
|
28
28
|
|
|
29
|
-
compose3x3transform(m3, position.x, position.y, scale.x, scale.y, rotation);
|
|
29
|
+
compose3x3transform(m3, position.x, position.y, scale.x, scale.y,0,0, rotation);
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
/*
|
|
@@ -346,6 +346,16 @@ class View {
|
|
|
346
346
|
this.on.unlinked.send0();
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
*
|
|
351
|
+
* @param {View[]} children
|
|
352
|
+
*/
|
|
353
|
+
addChildren(children) {
|
|
354
|
+
for (let i = 0; i < children.length; i++) {
|
|
355
|
+
this.addChild(children[i]);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
349
359
|
/**
|
|
350
360
|
*
|
|
351
361
|
* @param {View} child
|
|
@@ -725,6 +735,18 @@ class View {
|
|
|
725
735
|
}
|
|
726
736
|
}
|
|
727
737
|
|
|
738
|
+
/**
|
|
739
|
+
*
|
|
740
|
+
* @param {Object} hash
|
|
741
|
+
*/
|
|
742
|
+
attr(hash) {
|
|
743
|
+
for (let propertyName in hash) {
|
|
744
|
+
if (hash.hasOwnProperty(propertyName)) {
|
|
745
|
+
this.el.setAttribute(propertyName, hash[propertyName]);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
728
750
|
/**
|
|
729
751
|
*
|
|
730
752
|
* @param {Vector2} size
|
package/view/common/LabelView.js
CHANGED
|
@@ -16,7 +16,7 @@ import { frameThrottle } from "../../engine/graphics/FrameThrottle.js";
|
|
|
16
16
|
import { assert } from "../../core/assert.js";
|
|
17
17
|
import ObservedInteger from "../../core/model/ObservedInteger.js";
|
|
18
18
|
import { noop } from "../../core/function/Functions.js";
|
|
19
|
-
import { isTypedArray } from "../../core/
|
|
19
|
+
import { isTypedArray } from "../../core/collection/array/typed/isTypedArray.js";
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
* @param {number} tY translation Y offset
|
|
6
6
|
* @param {number} sX scale in X axis
|
|
7
7
|
* @param {number} sY scale in Y axis
|
|
8
|
+
* @param {number} cx center of rotation X
|
|
9
|
+
* @param {number} cy center of rotation Y
|
|
8
10
|
* @param {number} angle rotation angle
|
|
9
11
|
*/
|
|
10
|
-
export function compose3x3transform(result, tX, tY, sX, sY, angle) {
|
|
11
|
-
/**
|
|
12
|
-
* Center of rotation
|
|
13
|
-
* @type {number}
|
|
14
|
-
*/
|
|
15
|
-
const cx = 0;
|
|
16
|
-
const cy = 0;
|
|
17
|
-
|
|
12
|
+
export function compose3x3transform(result, tX, tY, sX, sY, cx, cy, angle) {
|
|
18
13
|
const neg_angle = -angle;
|
|
19
14
|
|
|
20
15
|
const sin = Math.sin(neg_angle);
|
|
@@ -32,3 +27,32 @@ export function compose3x3transform(result, tX, tY, sX, sY, angle) {
|
|
|
32
27
|
result[7] = 0;
|
|
33
28
|
result[8] = 1;
|
|
34
29
|
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {number[]|Float32Array} result
|
|
34
|
+
* @param {number} tX
|
|
35
|
+
* @param {number} tY
|
|
36
|
+
*/
|
|
37
|
+
export function m3_from_translation(result, tX, tY) {
|
|
38
|
+
result[0] = 1;
|
|
39
|
+
result[1] = 0;
|
|
40
|
+
result[2] = tX;
|
|
41
|
+
|
|
42
|
+
result[3] = 0;
|
|
43
|
+
result[4] = 1;
|
|
44
|
+
result[5] = tY;
|
|
45
|
+
|
|
46
|
+
result[6] = 0;
|
|
47
|
+
result[7] = 0;
|
|
48
|
+
result[8] = 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @see https://stackoverflow.com/questions/45159314/decompose-2d-transformation-matrix
|
|
53
|
+
* @param {mat3|number[]|Float32Array} m3
|
|
54
|
+
* @returns {number}
|
|
55
|
+
*/
|
|
56
|
+
export function m3_extract_rotation(m3) {
|
|
57
|
+
return Math.atan2(m3[3], m3[0]);
|
|
58
|
+
}
|
|
@@ -10,10 +10,10 @@ import Signal from "../../../core/events/signal/Signal.js";
|
|
|
10
10
|
import ObservedBoolean from "../../../core/model/ObservedBoolean.js";
|
|
11
11
|
import ObservedEnum from "../../../core/model/ObservedEnum.js";
|
|
12
12
|
import ObservedString from "../../../core/model/ObservedString.js";
|
|
13
|
-
import { isTypedArray } from "../../../core/json/JsonUtils.js";
|
|
14
13
|
import { Color } from "../../../core/color/Color.js";
|
|
15
14
|
import View from "../../View.js";
|
|
16
15
|
import ObservedInteger from "../../../core/model/ObservedInteger.js";
|
|
16
|
+
import { isTypedArray } from "../../../core/collection/array/typed/isTypedArray.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
@@ -33,7 +33,7 @@ class DropDownSelectionView extends View {
|
|
|
33
33
|
this.bindSignal(this.model.on.added, this.handleAdded, this);
|
|
34
34
|
this.bindSignal(this.model.on.removed, this.handleRemoved, this);
|
|
35
35
|
|
|
36
|
-
if(changeListener !== undefined) {
|
|
36
|
+
if (changeListener !== undefined) {
|
|
37
37
|
|
|
38
38
|
elRoot.addEventListener('change', (event) => {
|
|
39
39
|
const id = event.target.value;
|
|
@@ -139,10 +139,18 @@ class DropDownSelectionView extends View {
|
|
|
139
139
|
return this.getValueById(id);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {T} v
|
|
145
|
+
*/
|
|
146
|
+
setSelectedValue(v) {
|
|
147
|
+
this.el.selectedIndex = this.model.indexOf(v);
|
|
148
|
+
}
|
|
144
149
|
|
|
150
|
+
link() {
|
|
145
151
|
this.model.forEach(this.handleAdded, this);
|
|
152
|
+
|
|
153
|
+
super.link();
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
unlink() {
|
|
@@ -62,7 +62,9 @@ class ImageView extends View {
|
|
|
62
62
|
*/
|
|
63
63
|
let src;
|
|
64
64
|
|
|
65
|
-
if (
|
|
65
|
+
if (url === null || url === undefined) {
|
|
66
|
+
src = '';
|
|
67
|
+
} else if (typeof url === "string") {
|
|
66
68
|
src = url;
|
|
67
69
|
} else if (typeof url === "object" && typeof url.getValue === "function") {
|
|
68
70
|
src = url.getValue();
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { assert } from "../assert.js";
|
|
2
|
-
import Signal from "../events/signal/Signal.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {Number} value
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
function ObservedReal(value) {
|
|
10
|
-
assert.equal(typeof value, "number", `Value must be of type "number", instead was "${typeof value}"`);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @type {Number}
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
this.__value = value;
|
|
18
|
-
|
|
19
|
-
this.onChanged = new Signal();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Number} value
|
|
25
|
-
* @returns {ObservedReal}
|
|
26
|
-
*/
|
|
27
|
-
ObservedReal.prototype.set = function (value) {
|
|
28
|
-
assert.equal(typeof value, "number", `Value must be of type "number", instead was "${typeof value}"`);
|
|
29
|
-
|
|
30
|
-
const oldValue = this.__value;
|
|
31
|
-
if (oldValue !== value) {
|
|
32
|
-
this.__value = value;
|
|
33
|
-
this.onChanged.dispatch(value, oldValue);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return this;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @returns {Number}
|
|
42
|
-
*/
|
|
43
|
-
ObservedReal.prototype.getValue = function () {
|
|
44
|
-
return this.__value;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
ObservedReal.prototype.toJSON = function () {
|
|
48
|
-
return this.__value;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
ObservedReal.prototype.fromJSON = function (obj) {
|
|
52
|
-
this.set(obj);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default ObservedReal;
|
|
File without changes
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { inverseLerp } from "../../../../../core/math/inverseLerp.js";
|
|
2
|
-
|
|
3
|
-
export function attenuateSoundLinear(distance, min, max) {
|
|
4
|
-
if (distance <= min) {
|
|
5
|
-
return 1;
|
|
6
|
-
} else if (distance >= max) {
|
|
7
|
-
return 0;
|
|
8
|
-
} else {
|
|
9
|
-
return inverseLerp(max, min, distance);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { CellFilter } from "../CellFilter.js";
|
|
2
|
-
import { assert } from "../../../core/assert.js";
|
|
3
|
-
|
|
4
|
-
export class CellFilterReadGridLayer extends CellFilter {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {string}
|
|
11
|
-
*/
|
|
12
|
-
this.layerId = null;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {GridDataLayer}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
this.__layer = null;
|
|
20
|
-
|
|
21
|
-
this.__u_scale = 0;
|
|
22
|
-
this.__v_scale = 0;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @type {Sampler2D}
|
|
26
|
-
* @private
|
|
27
|
-
*/
|
|
28
|
-
this.__sampler = null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
initialize(grid, seed) {
|
|
32
|
-
super.initialize(grid, seed);
|
|
33
|
-
|
|
34
|
-
this.__layer = grid.getLayerById(this.layerId);
|
|
35
|
-
|
|
36
|
-
// cache required values
|
|
37
|
-
this.__sampler = this.__layer.sampler;
|
|
38
|
-
|
|
39
|
-
this.__u_scale = this.__sampler.width / grid.width;
|
|
40
|
-
this.__v_scale = this.__sampler.height / grid.height;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {string} layer
|
|
46
|
-
* @returns {CellFilterReadGridLayer}
|
|
47
|
-
*/
|
|
48
|
-
static from(layer) {
|
|
49
|
-
assert.typeOf(layer, 'string', 'layer');
|
|
50
|
-
|
|
51
|
-
const r = new CellFilterReadGridLayer();
|
|
52
|
-
|
|
53
|
-
r.layerId = layer;
|
|
54
|
-
|
|
55
|
-
return r;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
execute(grid, x, y, rotation) {
|
|
59
|
-
|
|
60
|
-
//convert to UV
|
|
61
|
-
const sampler_x = x * this.__u_scale;
|
|
62
|
-
const sampler_y = y * this.__v_scale;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* @type {Sampler2D}
|
|
68
|
-
*/
|
|
69
|
-
const sampler = this.__sampler;
|
|
70
|
-
|
|
71
|
-
return sampler.sampleChannelBilinear(sampler_x, sampler_y, 0);
|
|
72
|
-
}
|
|
73
|
-
}
|