@woosh/meep-engine 2.39.6 → 2.39.10
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/geom/3d/triangle/computeTriangleRayIntersection.js +39 -0
- package/engine/Engine.js +0 -17
- package/engine/graphics/ecs/camera/Camera.js +5 -4
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +8 -2
- package/engine/graphics/ecs/path/tube/TubePathStyle.js +18 -1
- package/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +25 -5
- package/engine/scene/transitionToScene.js +2 -1
- package/generation/example/main.js +2 -1
- package/package.json +1 -1
- package/samples/terrain/from_image.js +2 -1
- package/view/task/TaskLoadingScreen.js +9 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v3_dot } from "../../v3_dot.js";
|
|
2
|
+
import { assert } from "../../../assert.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
|
|
@@ -29,6 +30,44 @@ export function computeTriangleRayIntersection(
|
|
|
29
30
|
bx, by, bz,
|
|
30
31
|
cx, cy, cz
|
|
31
32
|
) {
|
|
33
|
+
assert.isNumber(ax,'ax');
|
|
34
|
+
assert.isNumber(ay,'ay');
|
|
35
|
+
assert.isNumber(az,'az');
|
|
36
|
+
|
|
37
|
+
assert.isNumber(bx,'bx');
|
|
38
|
+
assert.isNumber(by,'by');
|
|
39
|
+
assert.isNumber(bz,'bz');
|
|
40
|
+
|
|
41
|
+
assert.isNumber(cx,'cx');
|
|
42
|
+
assert.isNumber(cy,'cy');
|
|
43
|
+
assert.isNumber(cz,'cz');
|
|
44
|
+
|
|
45
|
+
// nan checks
|
|
46
|
+
assert.notNaN(ax,'ax');
|
|
47
|
+
assert.notNaN(ay,'ay');
|
|
48
|
+
assert.notNaN(az,'az');
|
|
49
|
+
|
|
50
|
+
assert.notNaN(bx,'bx');
|
|
51
|
+
assert.notNaN(by,'by');
|
|
52
|
+
assert.notNaN(bz,'bz');
|
|
53
|
+
|
|
54
|
+
assert.notNaN(cx,'cx');
|
|
55
|
+
assert.notNaN(cy,'cy');
|
|
56
|
+
assert.notNaN(cz,'cz');
|
|
57
|
+
|
|
58
|
+
// finate number check
|
|
59
|
+
assert.isFiniteNumber(ax,'ax');
|
|
60
|
+
assert.isFiniteNumber(ay,'ay');
|
|
61
|
+
assert.isFiniteNumber(az,'az');
|
|
62
|
+
|
|
63
|
+
assert.isFiniteNumber(bx,'bx');
|
|
64
|
+
assert.isFiniteNumber(by,'by');
|
|
65
|
+
assert.isFiniteNumber(bz,'bz');
|
|
66
|
+
|
|
67
|
+
assert.isFiniteNumber(cx,'cx');
|
|
68
|
+
assert.isFiniteNumber(cy,'cy');
|
|
69
|
+
assert.isFiniteNumber(cz,'cz');
|
|
70
|
+
|
|
32
71
|
|
|
33
72
|
// edge1 = a - b
|
|
34
73
|
const edge1_x = bx - ax;
|
package/engine/Engine.js
CHANGED
|
@@ -34,7 +34,6 @@ import { MetricCollection } from "./development/performance/MetricCollection.js"
|
|
|
34
34
|
import { PeriodicConsolePrinter } from "./development/performance/monitor/PeriodicConsolePrinter.js";
|
|
35
35
|
import { MetricStatistics } from "./development/performance/MetricStatistics.js";
|
|
36
36
|
import { logger } from "./logging/GlobalLogger.js";
|
|
37
|
-
import { TaskLoadingScreen } from "../view/task/TaskLoadingScreen.js";
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
function EngineSettings() {
|
|
@@ -406,18 +405,6 @@ class Engine {
|
|
|
406
405
|
}
|
|
407
406
|
}
|
|
408
407
|
|
|
409
|
-
/**
|
|
410
|
-
* @deprecated Use {@link TaskLoadingScreen#load} instead
|
|
411
|
-
* @param {Task|TaskGroup} task
|
|
412
|
-
* @returns {Promise<any>}
|
|
413
|
-
*/
|
|
414
|
-
loadSlowTask(task) {
|
|
415
|
-
assert.defined(task, 'task');
|
|
416
|
-
assert.notNull(task, 'task');
|
|
417
|
-
|
|
418
|
-
return TaskLoadingScreen.load(this, task);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
408
|
/**
|
|
422
409
|
* Startup
|
|
423
410
|
* @returns {Promise}
|
|
@@ -527,8 +514,4 @@ class Engine {
|
|
|
527
514
|
*/
|
|
528
515
|
Engine.prototype.isEngine = true;
|
|
529
516
|
|
|
530
|
-
function printError(reason) {
|
|
531
|
-
logger.error(reason);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
517
|
export default Engine;
|
|
@@ -23,6 +23,9 @@ export const ProjectionType = {
|
|
|
23
23
|
Orthographic: "orthographic"
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @class
|
|
28
|
+
*/
|
|
26
29
|
export class Camera {
|
|
27
30
|
constructor() {
|
|
28
31
|
/**
|
|
@@ -176,7 +179,7 @@ export class Camera {
|
|
|
176
179
|
// assert.ok(y >= -1, `Y(=${y}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
177
180
|
// assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
178
181
|
|
|
179
|
-
if (camera.isPerspectiveCamera) {
|
|
182
|
+
if (camera.isPerspectiveCamera || camera.isOrthographicCamera) {
|
|
180
183
|
scratch_v3_1.setFromMatrixPosition(camera.matrixWorld.elements);
|
|
181
184
|
|
|
182
185
|
scratch_v3_0.set(x, y, 0.5);
|
|
@@ -197,9 +200,7 @@ export class Camera {
|
|
|
197
200
|
source.copy(scratch_v3_1);
|
|
198
201
|
direction.copy(scratch_v3_0);
|
|
199
202
|
|
|
200
|
-
}
|
|
201
|
-
throw new Error('Unsupported camera type: "Orthographic" ');
|
|
202
|
-
} else {
|
|
203
|
+
} else {
|
|
203
204
|
throw new Error('Unsupported camera type');
|
|
204
205
|
}
|
|
205
206
|
}
|
|
@@ -70,6 +70,7 @@ import { BasicMaterialDefinition } from "./tube/BasicMaterialDefinition.js";
|
|
|
70
70
|
import '../../../../../../../css/game.scss';
|
|
71
71
|
import { GizmoRenderingPlugin } from "../../render/gizmo/GizmoRenderingPlugin.js";
|
|
72
72
|
import { PathNormalType } from "./tube/PathNormalType.js";
|
|
73
|
+
import { Camera, ProjectionType } from "../camera/Camera.js";
|
|
73
74
|
|
|
74
75
|
const engineHarness = new EngineHarness();
|
|
75
76
|
|
|
@@ -427,6 +428,11 @@ function makePath({
|
|
|
427
428
|
function main(engine) {
|
|
428
429
|
EngineHarness.buildBasics({ engine });
|
|
429
430
|
|
|
431
|
+
const ecd = engine.entityManager.dataset;
|
|
432
|
+
|
|
433
|
+
const cam = ecd.getAnyComponent(Camera);
|
|
434
|
+
cam.component.projectionType.set(ProjectionType.Orthographic);
|
|
435
|
+
|
|
430
436
|
makePath({
|
|
431
437
|
points: [
|
|
432
438
|
3, 1, 1,
|
|
@@ -437,7 +443,7 @@ function main(engine) {
|
|
|
437
443
|
3, 1, 8
|
|
438
444
|
],
|
|
439
445
|
interp: InterpolationType.Linear
|
|
440
|
-
}).build(
|
|
446
|
+
}).build(ecd);
|
|
441
447
|
|
|
442
448
|
makePath({
|
|
443
449
|
points: [
|
|
@@ -447,7 +453,7 @@ function main(engine) {
|
|
|
447
453
|
16.719999313354492, 3.130000114440918, -6.889999866485596
|
|
448
454
|
],
|
|
449
455
|
interp: InterpolationType.Linear
|
|
450
|
-
}).build(
|
|
456
|
+
}).build(ecd);
|
|
451
457
|
}
|
|
452
458
|
|
|
453
459
|
init(engineHarness);
|
|
@@ -116,6 +116,23 @@ export class TubePathStyle {
|
|
|
116
116
|
return r;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @param {string|{r:number,g:number,b:number}} color
|
|
122
|
+
* @param material_type
|
|
123
|
+
* @param material
|
|
124
|
+
* @param opacity
|
|
125
|
+
* @param width
|
|
126
|
+
* @param radial_resolution
|
|
127
|
+
* @param resolution
|
|
128
|
+
* @param cast_shadow
|
|
129
|
+
* @param receive_shadow
|
|
130
|
+
* @param path_mask
|
|
131
|
+
* @param cap_type
|
|
132
|
+
* @param shape
|
|
133
|
+
* @param path_normal
|
|
134
|
+
* @param path_normal_type
|
|
135
|
+
*/
|
|
119
136
|
fromJSON({
|
|
120
137
|
color = DEFAULT_COLOR,
|
|
121
138
|
material_type,
|
|
@@ -148,7 +165,7 @@ export class TubePathStyle {
|
|
|
148
165
|
assert.greaterThanOrEqual(path_mask.length, 2, 'path_mask length bust be at least 2');
|
|
149
166
|
assert.ok(path_mask.length % 2 === 0, 'path_mask length bust be multiple of 2');
|
|
150
167
|
assert.enum(cap_type, CapType, 'cap_type');
|
|
151
|
-
assert.enum(path_normal_type, 'path_normal_type');
|
|
168
|
+
assert.enum(path_normal_type, PathNormalType, 'path_normal_type');
|
|
152
169
|
|
|
153
170
|
if (shape === undefined) {
|
|
154
171
|
// legacy API, using circle
|
|
@@ -4,6 +4,7 @@ import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
|
4
4
|
import { computeTriangleRayIntersection } from "../../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
5
5
|
import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
|
|
6
6
|
import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
7
|
+
import { assert } from "../../../../../core/assert.js";
|
|
7
8
|
|
|
8
9
|
export class RaycastNearestHitComputingVisitor extends GeometrySpatialAcceleratorVisitor {
|
|
9
10
|
constructor() {
|
|
@@ -18,14 +19,14 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
18
19
|
this.__nearest_distance = Number.POSITIVE_INFINITY;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* @readonly
|
|
22
23
|
* @type {SurfacePoint3}
|
|
23
24
|
* @private
|
|
24
25
|
*/
|
|
25
26
|
this.__nearest_hit = new SurfacePoint3();
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* @readonly
|
|
29
30
|
* @type {SurfacePoint3}
|
|
30
31
|
* @private
|
|
31
32
|
*/
|
|
@@ -39,7 +40,18 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
39
40
|
*/
|
|
40
41
|
this.__hit_found = false;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @readonly
|
|
45
|
+
* @type {Vector3}
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
42
48
|
this.__ray_origin = new Vector3();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @readonly
|
|
52
|
+
* @type {Vector3}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
43
55
|
this.__ray_direction = new Vector3();
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -98,6 +110,8 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
98
110
|
|
|
99
111
|
const indices = this.__buffer_indices;
|
|
100
112
|
|
|
113
|
+
assert.lessThan(index3 + 2, indices.length, 'triangle index overflow, possibly geometry changed but tree was not rebuilt?');
|
|
114
|
+
|
|
101
115
|
const a = indices[index3];
|
|
102
116
|
const b = indices[index3 + 1];
|
|
103
117
|
const c = indices[index3 + 2];
|
|
@@ -111,6 +125,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
111
125
|
const b_address = b * stride + offset;
|
|
112
126
|
const c_address = c * stride + offset;
|
|
113
127
|
|
|
128
|
+
assert.lessThan(a_address + 2, vertices.length, 'a-vertex overflow');
|
|
129
|
+
assert.lessThan(b_address + 2, vertices.length, 'b-vertex overflow');
|
|
130
|
+
assert.lessThan(c_address + 2, vertices.length, 'c-vertex overflow');
|
|
131
|
+
|
|
114
132
|
const ax = vertices[a_address];
|
|
115
133
|
const ay = vertices[a_address + 1];
|
|
116
134
|
const az = vertices[a_address + 2];
|
|
@@ -123,8 +141,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
123
141
|
const cy = vertices[c_address + 1];
|
|
124
142
|
const cz = vertices[c_address + 2];
|
|
125
143
|
|
|
144
|
+
const temp_hit = this.__temp_hit;
|
|
145
|
+
|
|
126
146
|
if (computeTriangleRayIntersection(
|
|
127
|
-
|
|
147
|
+
temp_hit,
|
|
128
148
|
rayOrigin.x,
|
|
129
149
|
rayOrigin.y,
|
|
130
150
|
rayOrigin.z,
|
|
@@ -135,10 +155,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
135
155
|
bx, by, bz,
|
|
136
156
|
cx, cy, cz
|
|
137
157
|
)) {
|
|
138
|
-
const d =
|
|
158
|
+
const d = temp_hit.position.distanceSqrTo(rayOrigin);
|
|
139
159
|
|
|
140
160
|
if (d < this.__nearest_distance) {
|
|
141
|
-
this.__nearest_hit.copy(
|
|
161
|
+
this.__nearest_hit.copy(temp_hit);
|
|
142
162
|
this.__nearest_distance = d;
|
|
143
163
|
|
|
144
164
|
this.__hit_found = true;
|
|
@@ -6,6 +6,7 @@ import { noop } from "../../core/function/Functions.js";
|
|
|
6
6
|
import { compileAllMaterials } from "../graphics/ecs/compileAllMaterials.js";
|
|
7
7
|
import { createTaskWaitForMeshesToLoad } from "../graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js";
|
|
8
8
|
import { loadVisibleTerrainTiles } from "../ecs/terrain/util/loadVisibleTerrainTiles.js";
|
|
9
|
+
import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -117,7 +118,7 @@ export function transitionToScene({ tasks = [], scene, engine, name }) {
|
|
|
117
118
|
}
|
|
118
119
|
);
|
|
119
120
|
|
|
120
|
-
const promise =
|
|
121
|
+
const promise = TaskLoadingScreen.load(engine, taskGroup);
|
|
121
122
|
|
|
122
123
|
Task.joinAll(tasks, () => {
|
|
123
124
|
engine.executor.runMany(extraTasks);
|
|
@@ -28,6 +28,7 @@ import { MeshSystem } from "../../engine/graphics/ecs/mesh/MeshSystem.js";
|
|
|
28
28
|
import TopDownCameraControllerSystem from "../../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
29
29
|
import { TopDownCameraLanderSystem } from "../../engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js";
|
|
30
30
|
import LightSystem from "../../engine/graphics/ecs/light/LightSystem.js";
|
|
31
|
+
import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
|
|
31
32
|
|
|
32
33
|
function makeEngineConfig(engine) {
|
|
33
34
|
const config = new EngineConfiguration();
|
|
@@ -182,7 +183,7 @@ function main(engine) {
|
|
|
182
183
|
|
|
183
184
|
const tBuildLevel = prepare_gen_task({ ecd });
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
TaskLoadingScreen.load(engine, tBuildLevel);
|
|
186
187
|
|
|
187
188
|
engine.executor.runGroup(tBuildLevel);
|
|
188
189
|
|
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.39.
|
|
8
|
+
"version": "2.39.10",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from "../../engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
34
34
|
import { CellFilterAngleToNormal } from "../../generation/filtering/numeric/complex/CellFilterAngleToNormal.js";
|
|
35
35
|
import { CellFilterCache } from "../../generation/filtering/numeric/CellFilterCache.js";
|
|
36
|
+
import { TaskLoadingScreen } from "../../view/task/TaskLoadingScreen.js";
|
|
36
37
|
|
|
37
38
|
const HEIGHT_RANGE = 100;
|
|
38
39
|
|
|
@@ -267,7 +268,7 @@ async function main(engine) {
|
|
|
267
268
|
|
|
268
269
|
const task = theme_engine.apply(grid, ecd);
|
|
269
270
|
|
|
270
|
-
const promise_load =
|
|
271
|
+
const promise_load = TaskLoadingScreen.load(engine, task);
|
|
271
272
|
|
|
272
273
|
engine.executor.runGroup(task);
|
|
273
274
|
|
|
@@ -2,6 +2,7 @@ import TaskProgressView from "./TaskProgressView.js";
|
|
|
2
2
|
import { AssetLoaderStatusView } from "../asset/AssetLoaderStatusView.js";
|
|
3
3
|
import { logger } from "../../engine/logging/GlobalLogger.js";
|
|
4
4
|
import { array_remove_first } from "../../core/collection/array/array_remove_first.js";
|
|
5
|
+
import { assert } from "../../core/assert.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @type {TaskLoadingScreen}
|
|
@@ -41,6 +42,14 @@ export class TaskLoadingScreen {
|
|
|
41
42
|
* @returns {Promise<void>}
|
|
42
43
|
*/
|
|
43
44
|
async load(engine, task) {
|
|
45
|
+
|
|
46
|
+
assert.defined(task, 'task');
|
|
47
|
+
assert.notNull(task, 'task');
|
|
48
|
+
|
|
49
|
+
assert.defined(engine, 'engine');
|
|
50
|
+
assert.notNull(engine, 'engine');
|
|
51
|
+
|
|
52
|
+
|
|
44
53
|
await Promise.allSettled([this._active_promise]);
|
|
45
54
|
|
|
46
55
|
this._clearReleaseTimeout();
|