@woosh/meep-engine 2.36.28 → 2.37.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/core/bvh2/bvh3/{bvh_query_user_data_by_frustum.js → bvh_query_user_data_overlaps_frustum.js} +4 -5
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +1 -1
- package/core/color/Color.js +54 -3
- package/core/color/hsv2rgb.js +3 -3
- package/core/color/kelvin_to_rgb.js +51 -0
- package/core/color/kelvin_to_rgb.spec.js +61 -0
- package/core/color/linear_to_sRGB.js +17 -0
- package/core/color/prototype_kelvin_to_rgb.js +44 -0
- package/core/color/rgb_to_kelvin.js +34 -0
- package/core/color/rgb_to_kelvin.spec.js +15 -0
- package/core/color/sRGB_to_linear.js +16 -0
- package/core/geom/3d/frustum/read_frustum_planes_to_array.d.ts +3 -0
- package/{engine/graphics/render/forward_plus/cluster → core/geom/3d/frustum}/read_frustum_planes_to_array.js +1 -1
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +2 -2
- package/core/geom/LineSegment.js +2 -2
- package/core/geom/Vector3.js +14 -0
- package/core/math/DEG_TO_RAD.js +1 -0
- package/core/math/MathUtils.spec.js +0 -13
- package/core/math/RAD_TO_DEG.js +1 -0
- package/core/math/clamp01.js +15 -0
- package/core/math/fract.js +10 -0
- package/core/math/newton_solver_1d.js +21 -0
- package/core/math/smoothStep.js +3 -3
- package/core/math/solveQuadratic.js +32 -12
- package/core/math/solveQuadratic.spec.js +18 -0
- package/core/primitives/strings/StringUtils.js +10 -0
- package/core/process/task/TaskUtils.js +2 -2
- package/core/process/undo/Action.d.ts +2 -2
- package/core/process/undo/Action.js +4 -4
- package/core/process/undo/ActionGroup.js +4 -4
- package/core/process/undo/ActionProcessor.d.ts +6 -6
- package/core/process/undo/ActionProcessor.js +106 -16
- package/core/process/undo/ActionProcessor.spec.js +20 -15
- package/editor/actions/concrete/ComponentAddAction.js +2 -2
- package/editor/actions/concrete/ComponentRemoveAction.js +2 -2
- package/editor/actions/concrete/EntityCreateAction.js +2 -2
- package/editor/actions/concrete/EntityRemoveAction.js +2 -2
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +2 -2
- package/editor/actions/concrete/PatchTerrainHeightAction.js +2 -2
- package/editor/actions/concrete/PatchTerrainTextureAction.js +2 -2
- package/editor/actions/concrete/SelectionAddAction.js +2 -2
- package/editor/actions/concrete/SelectionClearAction.js +2 -2
- package/editor/actions/concrete/SelectionRemoveAction.js +2 -2
- package/editor/actions/concrete/TransformModifyAction.js +2 -2
- package/editor/actions/concrete/WriteGridValueAction.js +2 -2
- package/editor/view/EditorView.js +11 -9
- package/editor/view/ecs/components/color/GaugeView.js +2 -2
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +5 -4
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +5 -3
- package/engine/Clock.js +4 -0
- package/engine/UserController.js +2 -1
- package/engine/animation/behavior/animateProperty.js +6 -1
- package/engine/animation/keyed2/behavior/AnimationBehavior.js +0 -1
- package/engine/ecs/EntityBuilder.js +12 -1
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -1
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +2 -1
- package/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +14 -11
- package/engine/ecs/systems/AimControllerSystem.js +3 -2
- package/engine/ecs/systems/RangedAttackSystem.js +3 -2
- package/engine/ecs/systems/SteeringSystem.js +3 -3
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
- package/engine/graphics/GraphicsEngine.js +2 -1
- package/engine/graphics/camera/CameraShake.js +4 -4
- package/engine/graphics/ecs/animation/animator/graph/AnimationTransition.js +2 -2
- package/engine/graphics/ecs/camera/TiltCameraController.js +3 -2
- package/engine/graphics/ecs/compileAllMaterials.js +2 -2
- package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +10 -11
- package/engine/graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js +2 -2
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +19 -0
- package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +4 -2
- package/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.js +6 -0
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +31 -0
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -2
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -3
- package/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/engine/graphics/render/gizmo/Gizmo.js +3 -0
- package/engine/graphics/render/gizmo/GizmoRenderingPlugin.js +5 -0
- package/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +91 -0
- package/engine/graphics/render/view/CameraView.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +110 -18
- package/engine/graphics/three/OrbitControls.js +3 -2
- package/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.js +2 -2
- package/engine/graphics/util/makeMeshPreviewScene.js +11 -3
- package/engine/intelligence/behavior/Behavior.js +36 -17
- package/engine/intelligence/behavior/SelectorBehavior.js +6 -5
- package/engine/intelligence/behavior/composite/ParallelBehavior.js +0 -66
- package/engine/intelligence/behavior/composite/ParallelBehaviorSerializationAdapter.js +63 -0
- package/engine/intelligence/behavior/composite/SequenceBehavior.js +36 -11
- package/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +0 -2
- package/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.js +2 -4
- package/engine/intelligence/behavior/decorator/InverterBehavior.js +3 -3
- package/engine/intelligence/behavior/decorator/RepeatBehavior.js +0 -35
- package/engine/intelligence/behavior/decorator/RepeatBehavior.spec.js +0 -10
- package/engine/intelligence/behavior/decorator/RepeatBehaviorSerializationAdapter.js +37 -0
- package/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.js +0 -3
- package/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.js +5 -10
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +95 -7
- package/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +15 -8
- package/engine/intelligence/behavior/ecs/BehaviorSystem.js +28 -37
- package/engine/intelligence/behavior/ecs/DieBehavior.js +2 -7
- package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +2 -29
- package/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +29 -0
- package/engine/intelligence/behavior/primitive/ActionBehavior.js +6 -13
- package/engine/intelligence/behavior/primitive/FailingBehavior.js +1 -29
- package/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +29 -0
- package/engine/intelligence/behavior/primitive/PromiseBehavior.js +15 -3
- package/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +1 -5
- package/engine/intelligence/behavior/util/ConditionBehavior.js +1 -3
- package/engine/intelligence/behavior/util/ConditionBehavior.spec.js +1 -7
- package/engine/intelligence/behavior/util/ConditionalBehavior.js +3 -6
- package/engine/intelligence/behavior/util/DelayBehavior.js +2 -4
- package/engine/intelligence/behavior/util/SelectorBehavior.js +13 -12
- package/engine/intelligence/blackboard/AbstractBlackboard.js +16 -2
- package/engine/plugin/EnginePluginManager.js +4 -14
- package/engine/sound/ecs/emitter/SoundEmitter.js +3 -0
- package/generation/filtering/numeric/math/CellFilterSaturate.js +2 -2
- package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +3 -2
- package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +1 -1
- package/generation/rules/CellMatcherLayerBitMaskTest.js +3 -3
- package/package.json +1 -1
- package/view/elements/progress/SmoothProgressBar.js +2 -2
- package/view/elements/progress/segmented/SegmentedResourceBarView.js +3 -3
- package/view/elements/radial/RadialProgressView.js +2 -2
|
@@ -4,8 +4,8 @@ import { to_half_float_uint16 } from "../../../../core/binary/to_half_float_uint
|
|
|
4
4
|
import { compute_micron_buffer_array_constructor } from "./compute_micron_buffer_array_constructor.js";
|
|
5
5
|
import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
|
|
6
6
|
import { dataTypeByteSize } from "../../../../core/collection/table/DataTypeByteSizes.js";
|
|
7
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
8
7
|
import { UintArrayForCount } from "../../../../core/collection/array/typed/uint_array_for_count.js";
|
|
8
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @param {number} vertex_count
|
|
@@ -82,7 +82,7 @@ function copy_attribute_data(vertex_count, index_map_backward, itemSize, attribu
|
|
|
82
82
|
* @returns {number}
|
|
83
83
|
*/
|
|
84
84
|
function resample_normalized_uint16_to_uint8(value) {
|
|
85
|
-
const normalized =
|
|
85
|
+
const normalized = clamp01(value / 65535);
|
|
86
86
|
|
|
87
87
|
return Math.round(normalized * 255);
|
|
88
88
|
}
|
|
@@ -28,7 +28,9 @@ import RenderSystem from "../../../../../../ecs/systems/RenderSystem.js";
|
|
|
28
28
|
import { makeEngineOptionsModel } from "../../../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
29
29
|
import { enableEditor } from "../../../../../../../editor/enableEditor.js";
|
|
30
30
|
import { buildCubeURLs } from "../../../../../texture/cubemap/buildCubeURLs.js";
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
AmbientOcclusionPostProcessEffect
|
|
33
|
+
} from "../../../../../render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
32
34
|
import Vector2 from "../../../../../../../core/geom/Vector2.js";
|
|
33
35
|
import Vector3 from "../../../../../../../core/geom/Vector3.js";
|
|
34
36
|
import EntityBuilder from "../../../../../../ecs/EntityBuilder.js";
|
|
@@ -49,7 +51,6 @@ import ViewportPosition from "../../../../../../ecs/gui/position/ViewportPositio
|
|
|
49
51
|
import { CanvasView } from "../../../../../../../view/elements/CanvasView.js";
|
|
50
52
|
import convertSampler2D2Canvas from "../../../../../texture/sampler/Sampler2D2Canvas.js";
|
|
51
53
|
import Vector1 from "../../../../../../../core/geom/Vector1.js";
|
|
52
|
-
import { clamp } from "../../../../../../../core/math/clamp.js";
|
|
53
54
|
import { UnitCubeShape3D } from "../../../../../../../core/geom/3d/shape/UnitCubeShape3D.js";
|
|
54
55
|
import { ShadedGeometrySystem } from "../../../../../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
55
56
|
import { lut_to_sampler } from "./lut_to_sampler.js";
|
|
@@ -77,6 +78,7 @@ import { randomFloatBetween } from "../../../../../../../core/math/random/random
|
|
|
77
78
|
import { MicronRenderPlugin } from "../../../../../micron/plugin/MicronRenderPlugin.js";
|
|
78
79
|
import { obtainTerrain } from "../../../../../../ecs/terrain/util/obtainTerrain.js";
|
|
79
80
|
import { pick } from "../../../../../../../ecs/grid/pick.js";
|
|
81
|
+
import { clamp01 } from "../../../../../../../core/math/clamp01.js";
|
|
80
82
|
|
|
81
83
|
const engineHarness = new EngineHarness();
|
|
82
84
|
|
|
@@ -1225,7 +1227,7 @@ async function make_demo_volume({
|
|
|
1225
1227
|
|
|
1226
1228
|
const _t = pingpong(time_total + period_offset, period);
|
|
1227
1229
|
|
|
1228
|
-
const f =
|
|
1230
|
+
const f = clamp01(_t / period);
|
|
1229
1231
|
|
|
1230
1232
|
symbol.position.set(f);
|
|
1231
1233
|
|
|
@@ -21,7 +21,7 @@ import { computeFrustumCorners } from "./computeFrustumCorners.js";
|
|
|
21
21
|
import { arraySwapElements } from "../../../../core/collection/ArrayUtils.js";
|
|
22
22
|
import { compute_light_data_hash_0 } from "./cluster/compute_light_data_hash_0.js";
|
|
23
23
|
import { read_plane_pair } from "./cluster/read_plane_pair.js";
|
|
24
|
-
import { read_frustum_planes_to_array } from "
|
|
24
|
+
import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
|
|
25
25
|
import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
|
|
26
26
|
import { TextureBackedMemoryRegion } from "./data/TextureBackedMemoryRegion.js";
|
|
27
27
|
import { assert } from "../../../../core/assert.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
2
|
+
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
import { InstancedMeshGroup } from "../../geometry/instancing/InstancedMeshGroup.js";
|
|
4
|
+
import { BoxBufferGeometry, MeshBasicMaterial } from "three";
|
|
5
|
+
import { compose_matrix4_array } from "../../../../core/geom/3d/compose_matrix4_array.js";
|
|
6
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
7
|
+
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {number[]}
|
|
12
|
+
*/
|
|
13
|
+
const scratch_m4 = [];
|
|
14
|
+
|
|
15
|
+
export class GizmoShapeRenderingInterface {
|
|
16
|
+
constructor() {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {number[]}
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
this.__color = [1, 1, 1, 1];
|
|
24
|
+
|
|
25
|
+
this.__boxes_solid = InstancedMeshGroup.from(new BoxBufferGeometry(), new MeshBasicMaterial());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* RGBA
|
|
30
|
+
* @param {number[]} color
|
|
31
|
+
*/
|
|
32
|
+
set color(color) {
|
|
33
|
+
assert.defined(color, 'color');
|
|
34
|
+
assert.isArray(color, 'color');
|
|
35
|
+
assert.greaterThanOrEqual(color.length, 4);
|
|
36
|
+
|
|
37
|
+
array_copy(color, 0, this.__color, 0, 4);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {number[]} center
|
|
43
|
+
* @param {number[]} size
|
|
44
|
+
*/
|
|
45
|
+
draw_solid_cube(center, size) {
|
|
46
|
+
compose_matrix4_array(scratch_m4, Vector3.fromArray(center), Quaternion.identity, Vector3.fromArray(size));
|
|
47
|
+
const i = this.__boxes_solid.count;
|
|
48
|
+
|
|
49
|
+
this.__boxes_solid.setCount(i + 1);
|
|
50
|
+
this.__boxes_solid.setTransformAt(i, scratch_m4);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {number[]} center
|
|
56
|
+
* @param {number[]} size
|
|
57
|
+
*/
|
|
58
|
+
draw_wire_cube(center, size) {
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {number[]} from
|
|
65
|
+
* @param {number[]} to
|
|
66
|
+
*/
|
|
67
|
+
draw_line(from, to) {
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param {number[]} center
|
|
75
|
+
* @param {number} radius
|
|
76
|
+
*/
|
|
77
|
+
draw_solid_sphere(center, radius) {
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param {number[]} center
|
|
84
|
+
* @param {number} radius
|
|
85
|
+
*/
|
|
86
|
+
draw_wire_sphere() {
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
GizmoShapeRenderingInterface.INSTANCE = new GizmoShapeRenderingInterface();
|
|
@@ -3,7 +3,7 @@ import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
|
|
|
3
3
|
import { CameraViewFlags } from "./CameraViewFlags.js";
|
|
4
4
|
import { frustumFromCamera } from "../../ecs/camera/CameraSystem.js";
|
|
5
5
|
import { Frustum } from "three";
|
|
6
|
-
import { read_frustum_planes_to_array } from "
|
|
6
|
+
import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/read_frustum_planes_to_array.js";
|
|
7
7
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
8
8
|
import { compare_three_objects } from "../../three/compare_three_objects.js";
|
|
9
9
|
|
|
@@ -10,6 +10,7 @@ import { mix } from "../../../../core/math/mix.js";
|
|
|
10
10
|
import { BlendingType } from "./BlendingType.js";
|
|
11
11
|
import { assert } from "../../../../core/assert.js";
|
|
12
12
|
import { typedArrayConstructorByInstance } from "./typedArrayConstructorByInstance.js";
|
|
13
|
+
import { fract } from "../../../../core/math/fract.js";
|
|
13
14
|
|
|
14
15
|
function v2CrossMag(ax, ay, bx, by) {
|
|
15
16
|
return ax * by - ay * bx;
|
|
@@ -530,17 +531,18 @@ Sampler2D.prototype.get = function (x, y, result) {
|
|
|
530
531
|
};
|
|
531
532
|
|
|
532
533
|
/**
|
|
533
|
-
*
|
|
534
|
-
* @param {number}
|
|
535
|
-
* @param {number}
|
|
536
|
-
* @param {number}
|
|
537
|
-
* @param {number} c
|
|
538
|
-
* @param {number} d
|
|
539
|
-
* @returns {number}
|
|
534
|
+
*
|
|
535
|
+
* @param {number} u
|
|
536
|
+
* @param {number} v
|
|
537
|
+
* @param {number[]} result
|
|
540
538
|
*/
|
|
541
|
-
function
|
|
542
|
-
|
|
543
|
-
|
|
539
|
+
Sampler2D.prototype.sampleCatmullRomUV = function (u, v, result) {
|
|
540
|
+
const itemSize = this.itemSize;
|
|
541
|
+
|
|
542
|
+
for (let i = 0; i < itemSize; i++) {
|
|
543
|
+
result[i] = this.sampleChannelCatmullRomUV(u, v, i);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
544
546
|
|
|
545
547
|
/**
|
|
546
548
|
*
|
|
@@ -549,13 +551,87 @@ function bicubic_terp(t, a, b, c, d) {
|
|
|
549
551
|
* @param {number} channel
|
|
550
552
|
* @returns {number}
|
|
551
553
|
*/
|
|
552
|
-
Sampler2D.prototype.
|
|
554
|
+
Sampler2D.prototype.sampleChannelCatmullRomUV = function (u, v, channel) {
|
|
553
555
|
const x = u * (this.width - 1);
|
|
554
556
|
const y = v * (this.height - 1);
|
|
555
557
|
|
|
556
|
-
return this.
|
|
558
|
+
return this.sampleChannelCatmullRom(x, y, channel);
|
|
557
559
|
};
|
|
558
560
|
|
|
561
|
+
/**
|
|
562
|
+
*
|
|
563
|
+
* @see https://www.shadertoy.com/view/NsBfRG
|
|
564
|
+
* @see https://www.decarpentier.nl/2d-catmull-rom-in-4-samples
|
|
565
|
+
* @param {number} x
|
|
566
|
+
* @param {number} y
|
|
567
|
+
* @param {number} channel
|
|
568
|
+
* @returns {number}
|
|
569
|
+
*/
|
|
570
|
+
Sampler2D.prototype.sampleChannelCatmullRom = function (x, y, channel) {
|
|
571
|
+
// Based on the standard Catmull-Rom spline: w1*C1+w2*C2+w3*C3+w4*C4, where
|
|
572
|
+
// w1 = ((-0.5*f + 1.0)*f - 0.5)*f, w2 = (1.5*f - 2.5)*f*f + 1.0,
|
|
573
|
+
// w3 = ((-1.5*f + 2.0)*f + 0.5)*f and w4 = (0.5*f - 0.5)*f*f with f as the
|
|
574
|
+
// normalized interpolation position between C2 (at f=0) and C3 (at f=1).
|
|
575
|
+
|
|
576
|
+
// half_f is a sort of sub-pixelquad fraction, -1 <= half_f < 1.
|
|
577
|
+
const half_f_x = 2.0 * fract(0.5 * x - 0.25) - 1.0;
|
|
578
|
+
const half_f_y = 2.0 * fract(0.5 * y - 0.25) - 1.0;
|
|
579
|
+
|
|
580
|
+
// f is the regular sub-pixel fraction, 0 <= f < 1. This is equivalent to
|
|
581
|
+
// fract(uv * texSize - 0.5), but based on half_f to prevent rounding issues.
|
|
582
|
+
const f_x = fract(half_f_x);
|
|
583
|
+
const f_y = fract(half_f_y);
|
|
584
|
+
|
|
585
|
+
const s1_x = (0.5 * f_x - 0.5) * f_x; // = w1 / (1 - f)
|
|
586
|
+
const s1_y = (0.5 * f_y - 0.5) * f_y; // = w1 / (1 - f)
|
|
587
|
+
|
|
588
|
+
const s12_x = (-2.0 * f_x + 1.5) * f_x + 1.0; // = (w2 - w1) / (1 - f)
|
|
589
|
+
const s12_y = (-2.0 * f_y + 1.5) * f_y + 1.0; // = (w2 - w1) / (1 - f)
|
|
590
|
+
|
|
591
|
+
const s34_x = (2.0 * f_x - 2.5) * f_x - 0.5; // = (w4 - w3) / f
|
|
592
|
+
const s34_y = (2.0 * f_y - 2.5) * f_y - 0.5; // = (w4 - w3) / f
|
|
593
|
+
|
|
594
|
+
// positions is equivalent to: (floor(uv * texSize - 0.5).xyxy + 0.5 +
|
|
595
|
+
// vec4(-1.0 + w2 / (w2 - w1), 1.0 + w4 / (w4 - w3))) / texSize.xyxy.
|
|
596
|
+
const positions_x = (-f_x * s12_x + s1_x) / (s12_x) + x;
|
|
597
|
+
const positions_y = (-f_y * s12_y + s1_y) / (s12_y) + y;
|
|
598
|
+
const positions_z = (-f_x * s34_x + s1_x + s34_x) / (s34_x) + x;
|
|
599
|
+
const positions_w = (-f_y * s34_y + s1_y + s34_y) / (s34_y) + y;
|
|
600
|
+
|
|
601
|
+
// Determine if the output needs to be sign-flipped. Equivalent to .x*.y of
|
|
602
|
+
// (1.0 - 2.0 * floor(t - 2.0 * floor(0.5 * t))), where t is uv * texSize - 0.5.
|
|
603
|
+
const sign_flip = half_f_x * half_f_y > 0.0 ? 1.0 : -1.0;
|
|
604
|
+
|
|
605
|
+
// = (w2 - w1, w4 - w3)
|
|
606
|
+
const w_x = -f_x * s12_x + s12_x;
|
|
607
|
+
const w_y = -f_y * s12_y + s12_y;
|
|
608
|
+
const w_z = s34_x * f_x
|
|
609
|
+
const w_w = s34_y * f_y
|
|
610
|
+
|
|
611
|
+
const weights_x = w_x * w_y * sign_flip;
|
|
612
|
+
const weights_y = w_z * w_y * sign_flip;
|
|
613
|
+
const weights_z = w_x * w_w * sign_flip;
|
|
614
|
+
const weights_w = w_z * w_w * sign_flip;
|
|
615
|
+
|
|
616
|
+
return this.sampleChannelBilinear(positions_x, positions_y, channel) * weights_x +
|
|
617
|
+
this.sampleChannelBilinear(positions_z, positions_y, channel) * weights_y +
|
|
618
|
+
this.sampleChannelBilinear(positions_x, positions_w, channel) * weights_z +
|
|
619
|
+
this.sampleChannelBilinear(positions_z, positions_w, channel) * weights_w;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Based on code from From reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
|
|
624
|
+
* @param {number} t
|
|
625
|
+
* @param {number} a
|
|
626
|
+
* @param {number} b
|
|
627
|
+
* @param {number} c
|
|
628
|
+
* @param {number} d
|
|
629
|
+
* @returns {number}
|
|
630
|
+
*/
|
|
631
|
+
function bicubic_terp(t, a, b, c, d) {
|
|
632
|
+
return 0.5 * (c - a + (2.0 * a - 5.0 * b + 4.0 * c - d + (3.0 * (b - c) + d - a) * t) * t) * t + b;
|
|
633
|
+
}
|
|
634
|
+
|
|
559
635
|
/**
|
|
560
636
|
*
|
|
561
637
|
* @param {number} u
|
|
@@ -570,6 +646,20 @@ Sampler2D.prototype.sampleBicubicUV = function (u, v, result) {
|
|
|
570
646
|
}
|
|
571
647
|
};
|
|
572
648
|
|
|
649
|
+
/**
|
|
650
|
+
*
|
|
651
|
+
* @param {number} u
|
|
652
|
+
* @param {number} v
|
|
653
|
+
* @param {number} channel
|
|
654
|
+
* @returns {number}
|
|
655
|
+
*/
|
|
656
|
+
Sampler2D.prototype.sampleChannelBicubicUV = function (u, v, channel) {
|
|
657
|
+
const x = u * (this.width - 1);
|
|
658
|
+
const y = v * (this.height - 1);
|
|
659
|
+
|
|
660
|
+
return this.sampleChannelBicubic(x, y, channel);
|
|
661
|
+
};
|
|
662
|
+
|
|
573
663
|
/**
|
|
574
664
|
* Bicubic-filtered sampling
|
|
575
665
|
* @param {number} x
|
|
@@ -687,7 +777,6 @@ Sampler2D.prototype.sampleChannelBilinearUV = function (u, v, channel) {
|
|
|
687
777
|
return this.sampleChannelBilinear(x, y, channel);
|
|
688
778
|
};
|
|
689
779
|
|
|
690
|
-
|
|
691
780
|
/**
|
|
692
781
|
*
|
|
693
782
|
* @param {number} x
|
|
@@ -1287,15 +1376,18 @@ Sampler2D.prototype.zeroFill = function (x, y, width, height) {
|
|
|
1287
1376
|
*/
|
|
1288
1377
|
Sampler2D.prototype.fill = function (x, y, width, height, value) {
|
|
1289
1378
|
|
|
1290
|
-
const
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
const
|
|
1379
|
+
const _w = this.width;
|
|
1380
|
+
const _h = this.height;
|
|
1381
|
+
|
|
1382
|
+
const x0 = clamp(x, 0, _w);
|
|
1383
|
+
const y0 = clamp(y, 0, _h);
|
|
1384
|
+
const x1 = clamp(x + width, 0, _w);
|
|
1385
|
+
const y1 = clamp(y + height, 0, _h);
|
|
1294
1386
|
|
|
1295
1387
|
const data = this.data;
|
|
1296
1388
|
const itemSize = this.itemSize;
|
|
1297
1389
|
|
|
1298
|
-
const rowSize = itemSize *
|
|
1390
|
+
const rowSize = itemSize * _w;
|
|
1299
1391
|
|
|
1300
1392
|
let _y, _x, i;
|
|
1301
1393
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
import * as THREE from 'three';
|
|
11
|
+
import { DEG_TO_RAD } from "../../../core/math/DEG_TO_RAD.js";
|
|
11
12
|
|
|
12
13
|
// This set of controls performs orbiting, dollying (zooming), and panning.
|
|
13
14
|
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
@@ -360,7 +361,7 @@ function OrbitControls(object, domElement) {
|
|
|
360
361
|
var targetDistance = offset.length();
|
|
361
362
|
|
|
362
363
|
// half of the fov is center to top of screen
|
|
363
|
-
targetDistance *= Math.tan((scope.object.fov / 2) *
|
|
364
|
+
targetDistance *= Math.tan((scope.object.fov / 2) * DEG_TO_RAD);
|
|
364
365
|
|
|
365
366
|
// we use only clientHeight here so aspect ratio does not distort speed
|
|
366
367
|
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
@@ -1041,4 +1042,4 @@ Object.defineProperties(OrbitControls.prototype, {
|
|
|
1041
1042
|
|
|
1042
1043
|
});
|
|
1043
1044
|
|
|
1044
|
-
export { OrbitControls };
|
|
1045
|
+
export { OrbitControls };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { clamp } from "../../../../../core/math/clamp.js";
|
|
2
1
|
import { RIBBON_ATTRIBUTE_ADDRESS_AGE, RIBBON_ATTRIBUTE_ADDRESS_UV_OFFSET } from "../ribbon_attributes_spec.js";
|
|
2
|
+
import { clamp01 } from "../../../../../core/math/clamp01.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Fixed function simulation engine for ribbons
|
|
@@ -22,7 +22,7 @@ export class RibbonXFixedPhysicsSimulator {
|
|
|
22
22
|
// age the ribbon
|
|
23
23
|
const age = ribbon.incrementPointAttribute_Scalar(i, RIBBON_ATTRIBUTE_ADDRESS_AGE, timeDelta);
|
|
24
24
|
|
|
25
|
-
const relative_age =
|
|
25
|
+
const relative_age = clamp01(age / max_age);
|
|
26
26
|
|
|
27
27
|
// apply alpha over-time
|
|
28
28
|
ribbon.setPointAlpha(i, 1.0 - relative_age);
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AmbientLight as ThreeAmbientLight,
|
|
3
|
+
Box3,
|
|
4
|
+
DirectionalLight as ThreeDirectionalLight,
|
|
5
|
+
PerspectiveCamera as ThreePerspectiveCamera,
|
|
6
|
+
Scene as ThreeScene,
|
|
7
|
+
Vector3 as ThreeVector3
|
|
8
|
+
} from "three";
|
|
2
9
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
3
10
|
import { rootObject3DFastMatrixUpdate } from "../ecs/mesh/rootObject3DFastMatrixUpdate.js";
|
|
4
11
|
import { computeMeshPreviewCameraDistance } from "./computeMeshPreviewCameraDistance.js";
|
|
5
12
|
import { scaleObject3ToBox } from "./ScaleObject3ToBox.js";
|
|
13
|
+
import { DEG_TO_RAD } from "../../../core/math/DEG_TO_RAD.js";
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
*
|
|
@@ -62,7 +70,7 @@ export function makeMeshPreviewScene(mesh, size, focus) {
|
|
|
62
70
|
const focusHeight = (focus.y1 - focus.y0);
|
|
63
71
|
|
|
64
72
|
|
|
65
|
-
const fov = camera.fov *
|
|
73
|
+
const fov = camera.fov * DEG_TO_RAD;
|
|
66
74
|
const distance = computeMeshPreviewCameraDistance(focusHeight, fov, bBox.max.z);
|
|
67
75
|
|
|
68
76
|
const cameraPositionX = focus.x0 + (focus.x1 - focus.x0) / 2 - 0.5;
|
|
@@ -76,4 +84,4 @@ export function makeMeshPreviewScene(mesh, size, focus) {
|
|
|
76
84
|
// camera.far = bBox.size.z * mesh.scale.z+distance;
|
|
77
85
|
|
|
78
86
|
return { scene: scene, camera: camera };
|
|
79
|
-
}
|
|
87
|
+
}
|
|
@@ -1,55 +1,74 @@
|
|
|
1
1
|
import { BehaviorStatus } from "./BehaviorStatus.js";
|
|
2
|
-
import { assert } from "../../../core/assert.js";
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Base class of behavior tree implementation
|
|
5
|
+
*/
|
|
4
6
|
export class Behavior {
|
|
5
7
|
constructor() {
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* Any internal state used by the behavior
|
|
8
10
|
* @type {*}
|
|
9
11
|
*/
|
|
10
12
|
this.context = null;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
* @private
|
|
18
|
+
* @returns {BehaviorStatus}
|
|
19
|
+
*/
|
|
20
|
+
get __status() {
|
|
21
|
+
throw new Error('Deprecated');
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
25
|
+
* @deprecated
|
|
26
|
+
* @param {BehaviorStatus} v
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
set __status(v) {
|
|
30
|
+
throw new Error('Deprecated');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
22
35
|
* @returns {BehaviorStatus}
|
|
23
36
|
*/
|
|
24
37
|
getStatus() {
|
|
25
|
-
|
|
38
|
+
throw new Error('Deprecated');
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
/**
|
|
29
|
-
*
|
|
42
|
+
* @deprecated
|
|
30
43
|
* @param {BehaviorStatus} s
|
|
31
44
|
*/
|
|
32
45
|
setStatus(s) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.__status = s;
|
|
46
|
+
throw new Error('Deprecated');
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
/**
|
|
39
|
-
*
|
|
50
|
+
* Main update function
|
|
51
|
+
* @param {number} timeDelta time step in seconds
|
|
40
52
|
* @returns {BehaviorStatus}
|
|
41
53
|
*/
|
|
42
54
|
tick(timeDelta) {
|
|
43
55
|
throw new Error('Abstract method, needs to be overridden');
|
|
44
56
|
}
|
|
45
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Called before behavior gets executed via {@link #tick} for the first time
|
|
60
|
+
* Used to prepare the behavior for execution
|
|
61
|
+
* @param {*} [context]
|
|
62
|
+
*/
|
|
46
63
|
initialize(context) {
|
|
47
64
|
this.context = context;
|
|
48
|
-
this.__status = BehaviorStatus.Running;
|
|
49
65
|
}
|
|
50
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Called when behavior is finished, or interrupted
|
|
69
|
+
* Used to clean up any resources
|
|
70
|
+
*/
|
|
51
71
|
finalize() {
|
|
52
|
-
this.__status = BehaviorStatus.Initial;
|
|
53
72
|
}
|
|
54
73
|
}
|
|
55
74
|
|
|
@@ -21,20 +21,23 @@ export class SelectorBehavior extends CompositeBehavior {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
tick(timeDelta) {
|
|
24
|
+
if (this.__children.length < 1) {
|
|
25
|
+
// no options, nothing chosen
|
|
26
|
+
return BehaviorStatus.Failed;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
//keep going until a child behavior says it's running
|
|
25
|
-
for (
|
|
30
|
+
for (; ;) {
|
|
26
31
|
const s = this.__currentBehaviour.tick(timeDelta);
|
|
27
32
|
|
|
28
33
|
//if child succeeds or keeps running, do the same
|
|
29
34
|
if (s !== BehaviorStatus.Failed) {
|
|
30
|
-
this.__status = s;
|
|
31
35
|
return s;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
//Continue search for a fallback until the last child
|
|
35
39
|
const children = this.__children;
|
|
36
40
|
if (this.__currentBehaviourIndex + 1 >= children.length) {
|
|
37
|
-
this.__status = BehaviorStatus.Failed;
|
|
38
41
|
return BehaviorStatus.Failed;
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -48,7 +51,5 @@ export class SelectorBehavior extends CompositeBehavior {
|
|
|
48
51
|
this.__currentBehaviour = this.__children[0];
|
|
49
52
|
|
|
50
53
|
this.__currentBehaviour.initialize();
|
|
51
|
-
|
|
52
|
-
this.__status = BehaviorStatus.Running;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CompositeBehavior } from "./CompositeBehavior.js";
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
3
|
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
4
|
-
import { ObjectBasedClassSerializationAdapter } from "../../../ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
*
|
|
@@ -122,7 +121,6 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
122
121
|
|
|
123
122
|
this.__finalizeActiveChildren();
|
|
124
123
|
|
|
125
|
-
this.__status = BehaviorStatus.Succeeded;
|
|
126
124
|
return BehaviorStatus.Succeeded;
|
|
127
125
|
|
|
128
126
|
}
|
|
@@ -138,14 +136,12 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
138
136
|
|
|
139
137
|
this.__finalizeActiveChildren();
|
|
140
138
|
|
|
141
|
-
this.__status = BehaviorStatus.Failed;
|
|
142
139
|
return BehaviorStatus.Failed;
|
|
143
140
|
|
|
144
141
|
} else if (this.successPolicy === ParallelBehaviorPolicy.RequireAll) {
|
|
145
142
|
|
|
146
143
|
this.__finalizeActiveChildren();
|
|
147
144
|
|
|
148
|
-
this.__status = BehaviorStatus.Failed;
|
|
149
145
|
return BehaviorStatus.Failed;
|
|
150
146
|
|
|
151
147
|
}
|
|
@@ -155,22 +151,18 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
155
151
|
|
|
156
152
|
if (this.successCount === numChildren && this.successPolicy === ParallelBehaviorPolicy.RequireAll) {
|
|
157
153
|
|
|
158
|
-
this.__status = BehaviorStatus.Succeeded;
|
|
159
154
|
return BehaviorStatus.Succeeded;
|
|
160
155
|
|
|
161
156
|
} else if (this.failureCount === numChildren && this.failurePolicy === ParallelBehaviorPolicy.RequireAll) {
|
|
162
157
|
|
|
163
|
-
this.__status = BehaviorStatus.Failed;
|
|
164
158
|
return BehaviorStatus.Failed;
|
|
165
159
|
|
|
166
160
|
} else if ((this.failureCount + this.successCount) === numChildren) {
|
|
167
161
|
|
|
168
|
-
this.__status = BehaviorStatus.Failed;
|
|
169
162
|
return BehaviorStatus.Failed;
|
|
170
163
|
|
|
171
164
|
} else {
|
|
172
165
|
|
|
173
|
-
this.__status = BehaviorStatus.Running;
|
|
174
166
|
return BehaviorStatus.Running;
|
|
175
167
|
|
|
176
168
|
}
|
|
@@ -236,61 +228,3 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
236
228
|
|
|
237
229
|
ParallelBehavior.typeName = "ParallelBehavior";
|
|
238
230
|
|
|
239
|
-
export class ParallelBehaviorSerializationAdapter extends ObjectBasedClassSerializationAdapter {
|
|
240
|
-
constructor() {
|
|
241
|
-
super();
|
|
242
|
-
|
|
243
|
-
this.klass = ParallelBehavior;
|
|
244
|
-
this.version = 0;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
*
|
|
249
|
-
* @param {BinaryBuffer} buffer
|
|
250
|
-
* @param {ParallelBehavior} value
|
|
251
|
-
*/
|
|
252
|
-
serialize(buffer, value) {
|
|
253
|
-
|
|
254
|
-
buffer.writeUint8(value.getSuccessPolicy());
|
|
255
|
-
buffer.writeUint8(value.getFailurePolicy());
|
|
256
|
-
|
|
257
|
-
const children = value.getChildren();
|
|
258
|
-
|
|
259
|
-
const n = children.length;
|
|
260
|
-
|
|
261
|
-
buffer.writeUintVar(n);
|
|
262
|
-
|
|
263
|
-
for (let i = 0; i < n; i++) {
|
|
264
|
-
const behavior = children[i];
|
|
265
|
-
|
|
266
|
-
this.objectAdapter.serialize(buffer, behavior);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
* @param {BinaryBuffer} buffer
|
|
273
|
-
* @param {ParallelBehavior} value
|
|
274
|
-
*/
|
|
275
|
-
deserialize(buffer, value) {
|
|
276
|
-
const successPolicy = buffer.readUint8();
|
|
277
|
-
const failurePolicy = buffer.readUint8();
|
|
278
|
-
|
|
279
|
-
const count = buffer.readUintVar();
|
|
280
|
-
|
|
281
|
-
value.clearChildren();
|
|
282
|
-
|
|
283
|
-
for (let i = 0; i < count; i++) {
|
|
284
|
-
/**
|
|
285
|
-
*
|
|
286
|
-
* @type {Behavior}
|
|
287
|
-
*/
|
|
288
|
-
const child = this.objectAdapter.deserialize(buffer);
|
|
289
|
-
|
|
290
|
-
value.addChild(child);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
value.setFailurePolicy(failurePolicy);
|
|
294
|
-
value.setSuccessPolicy(successPolicy);
|
|
295
|
-
}
|
|
296
|
-
}
|