@woosh/meep-engine 2.36.26 → 2.36.29
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/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/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/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 +14 -24
- package/engine/graphics/ecs/light/LightSystem.js +2 -3
- 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/adapters/AbstractRenderAdapter.js +9 -0
- package/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.js +11 -0
- package/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +3 -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/micron/plugin/MicronRenderPlugin.js +0 -82
- package/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +28 -3
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -3
- 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/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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { clamp } from "../../../../../core/math/clamp.js";
|
|
2
1
|
import GuiControl from "../../../../../view/controller/controls/GuiControl.js";
|
|
3
2
|
import View from "../../../../../view/View.js";
|
|
4
3
|
import { PointerDevice } from "../../../../../engine/input/devices/PointerDevice.js";
|
|
@@ -7,10 +6,13 @@ import ObservedValue from "../../../../../core/model/ObservedValue.js";
|
|
|
7
6
|
import { ColorPickerView } from "../../../../../view/elements/ColorPickerView.js";
|
|
8
7
|
import Vector1 from "../../../../../core/geom/Vector1.js";
|
|
9
8
|
import Vector4 from "../../../../../core/geom/Vector4.js";
|
|
10
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ParameterLookupTableFlags
|
|
11
|
+
} from "../../../../../engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.js";
|
|
11
12
|
import { DomSizeObserver } from "../../../../../view/util/DomSizeObserver.js";
|
|
12
13
|
import { AutoCanvasView } from "../common/AutoCanvasView.js";
|
|
13
14
|
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
15
|
+
import { clamp01 } from "../../../../../core/math/clamp01.js";
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
class MarkerView extends View {
|
|
@@ -31,7 +33,6 @@ class MarkerView extends View {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
|
|
35
36
|
/**
|
|
36
37
|
*
|
|
37
38
|
* @param {Array.<MarkerView>} markers
|
|
@@ -74,7 +75,7 @@ function buildMarker(markers, model, update, canvas, selection) {
|
|
|
74
75
|
|
|
75
76
|
const positionDelta = delta.x / canvas.width;
|
|
76
77
|
|
|
77
|
-
const newPosition =
|
|
78
|
+
const newPosition = clamp01(oldPosition + positionDelta);
|
|
78
79
|
|
|
79
80
|
lut.positions[markerIndex] = newPosition;
|
|
80
81
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { clamp } from "../../../../../core/math/clamp.js";
|
|
2
1
|
import GuiControl from "../../../../../view/controller/controls/GuiControl.js";
|
|
3
2
|
import View from "../../../../../view/View.js";
|
|
4
3
|
import { PointerDevice } from "../../../../../engine/input/devices/PointerDevice.js";
|
|
5
4
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ParameterLookupTableFlags
|
|
7
|
+
} from "../../../../../engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.js";
|
|
7
8
|
import LabelView from "../../../../../view/common/LabelView.js";
|
|
8
9
|
import Vector1 from "../../../../../core/geom/Vector1.js";
|
|
10
|
+
import { clamp01 } from "../../../../../core/math/clamp01.js";
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
function computeVerticalValuePosition(v, min, max, height, lineWidth) {
|
|
@@ -151,7 +153,7 @@ function buildMarker(markers, model, update, canvas) {
|
|
|
151
153
|
|
|
152
154
|
const valueDelta = valueDeltaNormalized * dragScale;
|
|
153
155
|
|
|
154
|
-
const newPosition =
|
|
156
|
+
const newPosition = clamp01(oldPosition + positionDelta);
|
|
155
157
|
|
|
156
158
|
lut.positions[markerIndex] = newPosition;
|
|
157
159
|
|
package/engine/Clock.js
CHANGED
package/engine/UserController.js
CHANGED
|
@@ -5,6 +5,7 @@ import Vector3 from "../core/geom/Vector3.js";
|
|
|
5
5
|
import { Transform } from './ecs/transform/Transform.js';
|
|
6
6
|
import Hammer from 'Hammer';
|
|
7
7
|
import { Euler as ThreeEuler, Vector2 as ThreeVector2, Vector3 as ThreeVector3 } from 'three';
|
|
8
|
+
import { DEG_TO_RAD } from "../core/math/DEG_TO_RAD.js";
|
|
8
9
|
|
|
9
10
|
const keyboardRotationSpeed = 1.2;
|
|
10
11
|
|
|
@@ -37,7 +38,7 @@ function panUp(distance, object, result) {
|
|
|
37
38
|
// right and down are positive
|
|
38
39
|
function pan(delta, object, element, targetDistance, fov, result) {
|
|
39
40
|
// half of the fov is center to top of screen
|
|
40
|
-
targetDistance *= Math.tan((fov / 2) *
|
|
41
|
+
targetDistance *= Math.tan((fov / 2) * DEG_TO_RAD);
|
|
41
42
|
// we actually don't use screenWidth, since perspective camera is fixed to screen height
|
|
42
43
|
panLeft(2 * delta.x * targetDistance / element.clientHeight, object, result);
|
|
43
44
|
panUp(2 * delta.y * targetDistance / element.clientHeight, object, result);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TransitionPropertyVectorXBehavior
|
|
3
|
+
} from "../../../../model/game/story/behaviors/generic/TransitionPropertyVectorXBehavior.js";
|
|
2
4
|
import EntityBuilder from "../../ecs/EntityBuilder.js";
|
|
3
5
|
import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
4
6
|
import { SequenceBehavior } from "../../intelligence/behavior/composite/SequenceBehavior.js";
|
|
5
7
|
import { DieBehavior } from "../../intelligence/behavior/ecs/DieBehavior.js";
|
|
6
8
|
import { SendEventBehavior } from "../../../../model/game/util/behavior/SendEventBehavior.js";
|
|
7
9
|
import { SerializationMetadata } from "../../ecs/components/SerializationMetadata.js";
|
|
10
|
+
import { assert } from "../../../core/assert.js";
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
*
|
|
@@ -18,6 +21,8 @@ import { SerializationMetadata } from "../../ecs/components/SerializationMetadat
|
|
|
18
21
|
*/
|
|
19
22
|
export async function animateProperty(ecd, entity, component, property, target, time) {
|
|
20
23
|
|
|
24
|
+
assert.ok(ecd.entityExists(entity), `entity ${entity} doesn't exist`);
|
|
25
|
+
|
|
21
26
|
const builder = new EntityBuilder()
|
|
22
27
|
.add(SerializationMetadata.Transient)
|
|
23
28
|
.add(BehaviorComponent.fromOne(SequenceBehavior.from([
|
|
@@ -226,7 +226,18 @@ class EntityBuilder {
|
|
|
226
226
|
*/
|
|
227
227
|
promiseEvent(eventName) {
|
|
228
228
|
return new Promise((resolve, reject) => {
|
|
229
|
-
|
|
229
|
+
|
|
230
|
+
const handle_event = () => {
|
|
231
|
+
|
|
232
|
+
this.removeEventListener(eventName, handle_event);
|
|
233
|
+
this.removeEventListener(EventType.EntityRemoved, reject);
|
|
234
|
+
|
|
235
|
+
resolve();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
this.addEventListener(eventName, handle_event);
|
|
240
|
+
this.removeEventListener(EventType.EntityRemoved, reject);
|
|
230
241
|
});
|
|
231
242
|
}
|
|
232
243
|
|
|
@@ -8,6 +8,7 @@ import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
|
|
|
8
8
|
import { v3_computeOffsetVector } from "./IKMath.js";
|
|
9
9
|
import { v3_dot } from "../../../core/geom/v3_dot.js";
|
|
10
10
|
import { v3_length } from "../../../core/geom/v3_length.js";
|
|
11
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
11
12
|
|
|
12
13
|
const boneWorldPosition = new Vector3();
|
|
13
14
|
const boneWorldRotation = new Quaternion();
|
|
@@ -141,7 +142,7 @@ export class OneBoneSurfaceAlignmentSolver extends IKSolver {
|
|
|
141
142
|
//no penetration, hovering case, use hover distance for influence
|
|
142
143
|
const normalized_effector_distance = inverseLerp(0, bone_scale, delta_contact_c_length);
|
|
143
144
|
|
|
144
|
-
influence = 1 -
|
|
145
|
+
influence = 1 - clamp01(constraint.distance.normalizeValue(normalized_effector_distance));
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
if (influence <= 0) {
|
|
@@ -9,6 +9,7 @@ import { IKSolver } from "./IKSolver.js";
|
|
|
9
9
|
import { v3_computeOffsetVector } from "./IKMath.js";
|
|
10
10
|
import { v3_dot } from "../../../core/geom/v3_dot.js";
|
|
11
11
|
import { v3_length } from "../../../core/geom/v3_length.js";
|
|
12
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
12
13
|
|
|
13
14
|
const boneWorldPositionC = new Vector3();
|
|
14
15
|
const boneWorldPositionB = new Vector3();
|
|
@@ -280,7 +281,7 @@ export class TwoBoneInverseKinematicsSolver extends IKSolver {
|
|
|
280
281
|
//no penetration, hovering case, use hover distance for influence
|
|
281
282
|
const normalized_effector_distance = inverseLerp(0, limbLength, delta_contact_c_length);
|
|
282
283
|
|
|
283
|
-
influence = 1 -
|
|
284
|
+
influence = 1 - clamp01(constraint.distance.normalizeValue(normalized_effector_distance));
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
if (influence <= 0) {
|
|
@@ -25,8 +25,8 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
25
25
|
|
|
26
26
|
varying vec2 vUv;
|
|
27
27
|
|
|
28
|
-
const float c_samplesX =
|
|
29
|
-
const float c_samplesY =
|
|
28
|
+
const float c_samplesX = 5.0;
|
|
29
|
+
const float c_samplesY = 5.0;
|
|
30
30
|
|
|
31
31
|
const float c_halfSamplesX = c_samplesX / 2.0;
|
|
32
32
|
const float c_halfSamplesY = c_samplesY / 2.0;
|
|
@@ -95,15 +95,15 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
void main(){
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
//get world fragment position
|
|
99
|
+
vec3 worldPosition = computeWorldPosition();
|
|
100
|
+
|
|
101
|
+
vec2 fogUv = worldPosition.xz * uFogUvTransform.zw + uFogUvTransform.xy;
|
|
102
|
+
|
|
103
|
+
float fogValue = getFog( fogUv );
|
|
104
|
+
|
|
105
|
+
gl_FragColor = uColor;
|
|
106
|
+
gl_FragColor.a *= fogValue;
|
|
107
107
|
}
|
|
108
108
|
`;
|
|
109
109
|
}
|
|
@@ -127,6 +127,9 @@ export function buildScreenSpaceFogOfWarShader() {
|
|
|
127
127
|
uProjectionInverse: { type: 'm4', value: new Matrix4() },
|
|
128
128
|
uColor: { type: 'c', value: new Vector4(0, 0, 0, 1) },
|
|
129
129
|
uFogUvTransform: { type: 'v4', value: new Vector4(0, 0, 1, 1) },
|
|
130
|
+
/**
|
|
131
|
+
* Fog texture resolution
|
|
132
|
+
*/
|
|
130
133
|
uResolution: { type: 'v2', value: new Vector2(0, 0) }
|
|
131
134
|
};
|
|
132
135
|
|
|
@@ -7,6 +7,7 @@ import { System } from '../System.js';
|
|
|
7
7
|
import AimController from '../components/AimController.js';
|
|
8
8
|
import CharacterController from '../components/CharacterController.js';
|
|
9
9
|
import { Transform } from '../transform/Transform.js';
|
|
10
|
+
import { DEG_TO_RAD } from "../../../core/math/DEG_TO_RAD.js";
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class AimControllerSystem extends System {
|
|
@@ -14,7 +15,7 @@ class AimControllerSystem extends System {
|
|
|
14
15
|
super();
|
|
15
16
|
this.dependencies = [AimController];
|
|
16
17
|
|
|
17
|
-
this.sensitivity = 5 *
|
|
18
|
+
this.sensitivity = 5 * DEG_TO_RAD;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
add(component, entity) {
|
|
@@ -31,7 +32,7 @@ class AimControllerSystem extends System {
|
|
|
31
32
|
updateController(aimController, sensitivity);
|
|
32
33
|
//rotate player
|
|
33
34
|
const quaternion = new THREE.Quaternion();
|
|
34
|
-
quaternion.setFromAxisAngle(new THREE.Vector3(0, 1, 0), -aimController.lon *
|
|
35
|
+
quaternion.setFromAxisAngle(new THREE.Vector3(0, 1, 0), -aimController.lon * DEG_TO_RAD);
|
|
35
36
|
transform.rotation.copy(quaternion);
|
|
36
37
|
//rotate aim transform
|
|
37
38
|
const aimTransform = character.aim;
|
|
@@ -34,11 +34,12 @@ const intercept = (function () {
|
|
|
34
34
|
const c = toTarget.dot(toTarget);
|
|
35
35
|
|
|
36
36
|
// Solve quadratic
|
|
37
|
-
const ts =
|
|
37
|
+
const ts = [];
|
|
38
|
+
const root_count = solveQuadratic(ts, 0, a, b, c); // See quad(), below
|
|
38
39
|
|
|
39
40
|
// Find smallest positive solution
|
|
40
41
|
let sol = null;
|
|
41
|
-
if (
|
|
42
|
+
if (root_count > 0) {
|
|
42
43
|
const t0 = ts[0], t1 = ts[1];
|
|
43
44
|
let t = Math.min(t0, t1);
|
|
44
45
|
if (t < 0) t = Math.max(t0, t1);
|
|
@@ -39,11 +39,11 @@ function computeInterceptPoint(result, source, target, targetVelocity, sourceSpe
|
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
// Solve quadratic
|
|
42
|
-
const ts =
|
|
42
|
+
const ts = [];
|
|
43
|
+
const root_count = solveQuadratic(ts, 0, a, b, c); // See quad(), below
|
|
43
44
|
|
|
44
45
|
// Find smallest positive solution
|
|
45
|
-
|
|
46
|
-
if (ts) {
|
|
46
|
+
if (root_count > 0) {
|
|
47
47
|
const t0 = ts[0], t1 = ts[1];
|
|
48
48
|
let t = Math.min(t0, t1);
|
|
49
49
|
if (t < 0) t = Math.max(t0, t1);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex on 13/05/2016.
|
|
3
3
|
*/
|
|
4
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
5
4
|
import { min2 } from "../../../../core/math/min2.js";
|
|
6
5
|
import { System } from '../../System.js';
|
|
7
6
|
import { Transform } from '../../transform/Transform.js';
|
|
@@ -16,6 +15,7 @@ import { assert } from "../../../../core/assert.js";
|
|
|
16
15
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
17
16
|
import { Deque } from "../../../../core/collection/queue/Deque.js";
|
|
18
17
|
import { obtainTerrain } from "../util/obtainTerrain.js";
|
|
18
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -235,7 +235,7 @@ export function alignToVector(rotation, direction, angularLimit, up = Vector3.up
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
const t =
|
|
238
|
+
const t = clamp01(angularLimit / angle);
|
|
239
239
|
|
|
240
240
|
// TODO Consider replacing this with slerp
|
|
241
241
|
rotation.lerp(q_temp, t);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
2
1
|
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
3
2
|
import { ParameterLookupTable } from "../../../graphics/particles/particular/engine/parameter/ParameterLookupTable.js";
|
|
4
3
|
import { passThrough } from "../../../../core/function/Functions.js";
|
|
4
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const heatmap_lut = new ParameterLookupTable(4);
|
|
@@ -48,7 +48,7 @@ export function paintTerrainOverlayViaLookupTable({ overlay, sampler, lut = heat
|
|
|
48
48
|
|
|
49
49
|
const scaledPosition = lookupScaleFunction(p);
|
|
50
50
|
|
|
51
|
-
const position =
|
|
51
|
+
const position = clamp01(range.normalizeValue(scaledPosition));
|
|
52
52
|
|
|
53
53
|
lut.sample(position, colorSample);
|
|
54
54
|
|
|
@@ -39,6 +39,7 @@ import { CameraViewManager } from "./render/view/CameraViewManager.js";
|
|
|
39
39
|
import { StandardFrameBuffers } from "./StandardFrameBuffers.js";
|
|
40
40
|
import { load_environment_map } from "./texture/cubemap/load_environment_map.js";
|
|
41
41
|
import { CompositingStages } from "./composit/CompositingStages.js";
|
|
42
|
+
import { DEG_TO_RAD } from "../../core/math/DEG_TO_RAD.js";
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
*
|
|
@@ -493,7 +494,7 @@ GraphicsEngine.prototype.normalizeViewportPoint = function (input, result) {
|
|
|
493
494
|
*/
|
|
494
495
|
GraphicsEngine.prototype.viewportWorldSize = function (camera, zDistance, result) {
|
|
495
496
|
const size = this.viewport.size;
|
|
496
|
-
const angleY = camera.fov *
|
|
497
|
+
const angleY = camera.fov * DEG_TO_RAD;
|
|
497
498
|
const cameraZ = camera.position.z;
|
|
498
499
|
const distFromCamToPlane = Math.abs(cameraZ) + zDistance;
|
|
499
500
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
2
2
|
|
|
3
3
|
import SimplexNoise from 'simplex-noise';
|
|
4
|
-
import {
|
|
5
|
-
import { makeCubicCurve} from "../../../core/math/MathUtils.js";
|
|
4
|
+
import { makeCubicCurve } from "../../../core/math/MathUtils.js";
|
|
6
5
|
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
7
6
|
import { Behavior } from "../../intelligence/behavior/Behavior.js";
|
|
8
7
|
import { BehaviorStatus } from "../../intelligence/behavior/BehaviorStatus.js";
|
|
9
8
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
9
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
10
10
|
|
|
11
11
|
export class CameraShakeTraumaBehavior extends Behavior {
|
|
12
12
|
|
|
@@ -31,9 +31,9 @@ export class CameraShakeTraumaBehavior extends Behavior {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
tick(timeDelta) {
|
|
34
|
-
const shake = this.formula(
|
|
34
|
+
const shake = this.formula(clamp01(this.trauma));
|
|
35
35
|
|
|
36
|
-
this.trauma =
|
|
36
|
+
this.trauma = clamp01(this.trauma - timeDelta * this.decay);
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
this.shakeBehavior.strength = shake;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clamp } from "../../../../../../core/math/clamp.js";
|
|
2
1
|
import { lerp } from "../../../../../../core/math/lerp.js";
|
|
3
2
|
import { BlendStateMatrix } from "../blending/BlendStateMatrix.js";
|
|
3
|
+
import { clamp01 } from "../../../../../../core/math/clamp01.js";
|
|
4
4
|
|
|
5
5
|
export class AnimationTransition {
|
|
6
6
|
constructor() {
|
|
@@ -90,7 +90,7 @@ export class AnimationTransition {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
updateBlendsState() {
|
|
93
|
-
const t =
|
|
93
|
+
const t = clamp01(this.computeNormalizedTime());
|
|
94
94
|
|
|
95
95
|
BlendStateMatrix.lerp(this.blendState, this.source.blendState, this.target.blendState, t);
|
|
96
96
|
}
|
|
@@ -5,13 +5,14 @@ import { Object3D, Vector3 as ThreeVector3 } from 'three';
|
|
|
5
5
|
|
|
6
6
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
7
7
|
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
8
|
+
import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
|
|
8
9
|
|
|
9
10
|
const CC = function () {
|
|
10
11
|
this.target = new Vector3();
|
|
11
12
|
this.rotationAxis = new Vector3(0, 1, 0);
|
|
12
|
-
this.rotationAngle =
|
|
13
|
+
this.rotationAngle = DEG_TO_RAD * 0;
|
|
13
14
|
//angle between rotation axis and vector from target to position
|
|
14
|
-
this.tiltAngle =
|
|
15
|
+
this.tiltAngle = DEG_TO_RAD * 10;
|
|
15
16
|
|
|
16
17
|
this.distance = 100;
|
|
17
18
|
this.position = new Vector3();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Mesh, PlaneBufferGeometry } from "three";
|
|
2
|
-
import { clamp } from "../../../core/math/clamp.js";
|
|
3
2
|
import Task from "../../../core/process/task/Task.js";
|
|
4
3
|
import TaskSignal from "../../../core/process/task/TaskSignal.js";
|
|
5
4
|
import { collectIteratorValueToArray } from "../../../core/collection/IteratorUtils.js";
|
|
5
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Compile all materials found in the dataset
|
|
@@ -100,7 +100,7 @@ export function compileAllMaterials({ graphics, timeout = 0, includeHiddenLayers
|
|
|
100
100
|
|
|
101
101
|
const f = index / n;
|
|
102
102
|
|
|
103
|
-
return
|
|
103
|
+
return clamp01(f);
|
|
104
104
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
@@ -82,8 +82,6 @@ function makeIdMaterialStatic() {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const material_id_unskinned = makeIdMaterialStatic();
|
|
86
|
-
|
|
87
85
|
/**
|
|
88
86
|
*
|
|
89
87
|
* @type {WeakMap<Object3D, Object3D>}
|
|
@@ -95,26 +93,25 @@ const object_id_cache = new WeakMap();
|
|
|
95
93
|
* @param {Mesh|SkinnedMesh} object
|
|
96
94
|
*/
|
|
97
95
|
function obtain_id_mesh(object) {
|
|
98
|
-
|
|
96
|
+
let mesh = object_id_cache.get(object);
|
|
97
|
+
|
|
98
|
+
if (mesh === undefined) {
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
if (object.isSkinnedMesh) {
|
|
101
|
+
mesh = new SkinnedMesh(object.geometry, makeIdMaterialSkinned());
|
|
102
|
+
} else {
|
|
103
|
+
mesh = new Mesh(object.geometry, makeIdMaterialStatic());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
object_id_cache.set(object, mesh);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
|
-
let material, mesh;
|
|
105
109
|
if (object.isSkinnedMesh) {
|
|
106
|
-
material = makeIdMaterialSkinned();
|
|
107
|
-
mesh = new SkinnedMesh(object.geometry, material);
|
|
108
110
|
mesh.bindMatrix.copy(object.bindMatrix);
|
|
109
111
|
mesh.bindMatrixInverse.copy(object.bindMatrixInverse);
|
|
110
112
|
mesh.skeleton = object.skeleton;
|
|
111
|
-
} else {
|
|
112
|
-
material = makeIdMaterialStatic();
|
|
113
|
-
mesh = new Mesh(object.geometry, material);
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
object_id_cache.set(object, mesh);
|
|
117
|
-
|
|
118
115
|
return mesh;
|
|
119
116
|
}
|
|
120
117
|
|
|
@@ -185,13 +182,6 @@ export class OutlineRenderer {
|
|
|
185
182
|
*/
|
|
186
183
|
this.scene = null;
|
|
187
184
|
|
|
188
|
-
/**
|
|
189
|
-
*
|
|
190
|
-
* @type {HighlightRenderGroup}
|
|
191
|
-
* @private
|
|
192
|
-
*/
|
|
193
|
-
this.__current_group = null;
|
|
194
|
-
|
|
195
185
|
/**
|
|
196
186
|
*
|
|
197
187
|
* @type {HashMap<HighlightDefinition>}
|
|
@@ -585,10 +575,10 @@ export class OutlineRenderer {
|
|
|
585
575
|
|
|
586
576
|
const color = definition.color;
|
|
587
577
|
|
|
588
|
-
data[offset + 0] = color.r * 255;
|
|
589
|
-
data[offset + 1] = color.g * 255;
|
|
590
|
-
data[offset + 2] = color.b * 255;
|
|
591
|
-
data[offset + 3] = definition.opacity * 255;
|
|
578
|
+
data[offset + 0] = Math.round(color.r * 255);
|
|
579
|
+
data[offset + 1] = Math.round(color.g * 255);
|
|
580
|
+
data[offset + 2] = Math.round(color.b * 255);
|
|
581
|
+
data[offset + 3] = Math.round(definition.opacity * 255);
|
|
592
582
|
|
|
593
583
|
texture.needsUpdate = true;
|
|
594
584
|
}
|
|
@@ -183,11 +183,10 @@ class LightSystem extends AbstractContextSystem {
|
|
|
183
183
|
/**
|
|
184
184
|
*
|
|
185
185
|
* @param {Light} light
|
|
186
|
-
* @param {Transform} transform
|
|
187
186
|
* @param {number} lightEntity
|
|
188
187
|
* @private
|
|
189
188
|
*/
|
|
190
|
-
__visit_entity_to_update_shadow(light,
|
|
189
|
+
__visit_entity_to_update_shadow(light, lightEntity) {
|
|
191
190
|
/**
|
|
192
191
|
*
|
|
193
192
|
1) Calculate the 8 corners of the view frustum in world space. This can be done by using the inverse view-projection matrix to transform the 8 corners of the NDC cube (which in OpenGL is [‒1, 1] along each axis).
|
|
@@ -250,7 +249,7 @@ class LightSystem extends AbstractContextSystem {
|
|
|
250
249
|
return false;
|
|
251
250
|
}
|
|
252
251
|
|
|
253
|
-
dataset.
|
|
252
|
+
dataset.traverseComponents(Light, this.__visit_entity_to_update_shadow, this);
|
|
254
253
|
|
|
255
254
|
//stop further traversal
|
|
256
255
|
return false;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
2
1
|
import { max2 } from "../../../../core/math/max2.js";
|
|
3
2
|
import Mesh from "./Mesh.js";
|
|
4
3
|
import Task from "../../../../core/process/task/Task.js";
|
|
@@ -6,6 +5,7 @@ import TaskSignal from "../../../../core/process/task/TaskSignal.js";
|
|
|
6
5
|
import { assert } from "../../../../core/assert.js";
|
|
7
6
|
import { assetTypeByPath } from "./assetTypeByPath.js";
|
|
8
7
|
import { collectIteratorValueToArray } from "../../../../core/collection/IteratorUtils.js";
|
|
8
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Produces a task that will wait for all existing Meshes of a dataset to be loaded, will fail upon timeout being reached
|
|
@@ -96,7 +96,7 @@ export function createTaskWaitForMeshesToLoad(ecd, engine, timeout) {
|
|
|
96
96
|
|
|
97
97
|
const p = max2(progress, relativeExpiredTime);
|
|
98
98
|
|
|
99
|
-
return
|
|
99
|
+
return clamp01(p);
|
|
100
100
|
},
|
|
101
101
|
cycleFunction() {
|
|
102
102
|
currentTime = performance.now();
|
|
@@ -20,4 +20,10 @@ export class ShadedGeometrySystem extends System<ShadedGeometry> {
|
|
|
20
20
|
filter_function?: (entity: number, mesh: ShadedGeometry) => boolean,
|
|
21
21
|
filter_function_context?: any
|
|
22
22
|
): { entity: number, mesh: ShadedGeometry, contact: SurfacePoint3 }[]
|
|
23
|
+
|
|
24
|
+
queryOverlapFrustum(
|
|
25
|
+
result: ArrayLike<number>,
|
|
26
|
+
result_offset: number,
|
|
27
|
+
planes: ArrayLike<number>
|
|
28
|
+
): number
|
|
23
29
|
}
|
|
@@ -19,6 +19,9 @@ import Task from "../../../../core/process/task/Task.js";
|
|
|
19
19
|
import { RuntimeDrawMethodOptimizer } from "./render/optimization/RuntimeDrawMethodOptimizer.js";
|
|
20
20
|
import TaskSignal from "../../../../core/process/task/TaskSignal.js";
|
|
21
21
|
import TaskState from "../../../../core/process/task/TaskState.js";
|
|
22
|
+
import {
|
|
23
|
+
bvh_query_user_data_overlaps_frustum
|
|
24
|
+
} from "../../../../core/bvh2/bvh3/bvh_query_user_data_overlaps_frustum.js";
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -308,6 +311,21 @@ export class ShadedGeometrySystem extends System {
|
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
* @param {number[]} result entity IDs
|
|
317
|
+
* @param {number} result_offset offset into result array where to write first result into
|
|
318
|
+
* @param {number[]|ArrayLike<number>} planes
|
|
319
|
+
* @returns {number} number of results
|
|
320
|
+
*/
|
|
321
|
+
queryOverlapFrustum(
|
|
322
|
+
result,
|
|
323
|
+
result_offset,
|
|
324
|
+
planes
|
|
325
|
+
) {
|
|
326
|
+
return bvh_query_user_data_overlaps_frustum(result, result_offset, this.__bvh_binary, planes);
|
|
327
|
+
}
|
|
328
|
+
|
|
311
329
|
/**
|
|
312
330
|
*
|
|
313
331
|
* @param {number} origin_x
|
|
@@ -393,6 +411,7 @@ export class ShadedGeometrySystem extends System {
|
|
|
393
411
|
return result;
|
|
394
412
|
}
|
|
395
413
|
|
|
414
|
+
|
|
396
415
|
/**
|
|
397
416
|
*
|
|
398
417
|
* @param {SurfacePoint3} contact
|
|
@@ -3,7 +3,9 @@ import { InstancedRendererAdapter } from "./adapters/InstancedRendererAdapter.js
|
|
|
3
3
|
import { GenericRendererAdapter } from "./adapters/GenericRendererAdapter.js";
|
|
4
4
|
import { assert } from "../../../../../core/assert.js";
|
|
5
5
|
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
bvh_query_user_data_overlaps_frustum
|
|
8
|
+
} from "../../../../../core/bvh2/bvh3/bvh_query_user_data_overlaps_frustum.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
*
|
|
@@ -89,7 +91,7 @@ export class ShadedGeometryRendererContext {
|
|
|
89
91
|
|
|
90
92
|
|
|
91
93
|
// get all meshes
|
|
92
|
-
const intersection_count =
|
|
94
|
+
const intersection_count = bvh_query_user_data_overlaps_frustum(collection_array, 0, bvh, view.frustum);
|
|
93
95
|
|
|
94
96
|
const sg_component_index = ecd.computeComponentTypeIndex(ShadedGeometry);
|
|
95
97
|
|
|
@@ -27,6 +27,15 @@ export class AbstractRenderAdapter {
|
|
|
27
27
|
return 0;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Express intent to draw
|
|
32
|
+
* @param {ShadedGeometry} sg
|
|
33
|
+
* @returns {boolean} true if able to draw immediately, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
intend_draw(sg) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
/**
|
|
31
40
|
*
|
|
32
41
|
* @param {ShadedGeometry} sg
|