@woosh/meep-engine 2.35.9 → 2.35.13
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/binary/BinaryBuffer.js +65 -18
- package/engine/graphics/ecs/camera/Camera.d.ts +3 -0
- package/engine/graphics/ecs/camera/Camera.js +39 -1
- package/engine/graphics/ecs/camera/CameraSystem.js +25 -6
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +38 -3
- package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +19 -4
- package/engine/graphics/ecs/path/PathDisplaySystem.js +1 -1
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +19 -12
- package/engine/graphics/ecs/path/tube/TubePathStyle.d.ts +3 -0
- package/engine/graphics/ecs/path/tube/TubePathStyle.js +71 -2
- package/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +160 -0
- package/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +61 -0
- package/engine/graphics/ecs/path/tube/build/build_geometry_linear.js +56 -0
- package/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +165 -0
- package/engine/graphics/ecs/path/tube/build/estimatePathLength.js +17 -0
- package/engine/graphics/ecs/path/tube/build/estimatePathViaIterativeIntegral.js +37 -0
- package/engine/graphics/ecs/path/tube/build/makeTubeGeometry.js +161 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -1
- package/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +45 -76
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +19 -24
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -1
- package/engine/graphics/micron/render/v1/MaterialContext.js +1 -11
- package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +55 -2
- package/engine/graphics/micron/render/v1/MicronRenderContext.js +151 -0
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +24 -117
- package/engine/navigation/ecs/components/Path.js +5 -6
- package/package.json +1 -1
- package/engine/graphics/ecs/path/tube/TubePathBuilder.js +0 -522
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { VirtualGeometryBuilder } from "../VirtualGeometryBuilder.js";
|
|
2
1
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
3
|
-
import { VirtualGeometry } from "../../format/VirtualGeometry.js";
|
|
4
2
|
import { MaterialContext } from "./MaterialContext.js";
|
|
5
|
-
import { MaterialVertexSpec } from "./MaterialVertexSpec.js";
|
|
6
|
-
import { HashMap } from "../../../../../core/collection/HashMap.js";
|
|
7
|
-
import Signal from "../../../../../core/events/signal/Signal.js";
|
|
8
3
|
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
4
|
+
import { MicronRenderContext } from "./MicronRenderContext.js";
|
|
5
|
+
import { MaterialVertexSpec, MaterialVertexSpecFlags } from "./MaterialVertexSpec.js";
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
*
|
|
@@ -15,23 +12,6 @@ const scratch_mvc = new MaterialVertexSpec();
|
|
|
15
12
|
|
|
16
13
|
export class VGThreeRenderer {
|
|
17
14
|
constructor() {
|
|
18
|
-
this.geometry = new VirtualGeometry();
|
|
19
|
-
|
|
20
|
-
this.builder = new VirtualGeometryBuilder();
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {Map<MaterialVertexSpec, MaterialContext>}
|
|
25
|
-
*/
|
|
26
|
-
this.material_contexts = new HashMap();
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @type {MaterialContext[]}
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
this.__contexts_array = [];
|
|
34
|
-
|
|
35
15
|
/**
|
|
36
16
|
*
|
|
37
17
|
* @type {Object3D[]}
|
|
@@ -39,82 +19,51 @@ export class VGThreeRenderer {
|
|
|
39
19
|
*/
|
|
40
20
|
this.__inputs = [];
|
|
41
21
|
|
|
22
|
+
this.ctx = new MicronRenderContext();
|
|
23
|
+
|
|
42
24
|
this.on = {
|
|
43
25
|
/**
|
|
44
26
|
* @type {Signal<MaterialContext>}
|
|
45
27
|
*/
|
|
46
|
-
contextAdded:
|
|
28
|
+
contextAdded: this.ctx.on.contextAdded
|
|
47
29
|
};
|
|
48
30
|
}
|
|
49
31
|
|
|
32
|
+
get geometry() {
|
|
33
|
+
return this.ctx.geometry;
|
|
34
|
+
}
|
|
35
|
+
|
|
50
36
|
/**
|
|
51
37
|
* Enable/disable wireframe rendering
|
|
52
38
|
* @param {boolean} x
|
|
53
39
|
*/
|
|
54
40
|
set wireframe(x) {
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
ctx.compiled_material.wireframe = x;
|
|
59
|
-
|
|
60
|
-
});
|
|
41
|
+
this.ctx.wireframe = x;
|
|
61
42
|
}
|
|
62
43
|
|
|
63
|
-
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {VertexDataSpec} spec
|
|
66
|
-
* @param {Material} m
|
|
67
|
-
* @returns {MaterialContext}
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
__obtain_material(spec, m) {
|
|
71
|
-
scratch_mvc.material = m;
|
|
72
|
-
scratch_mvc.spec = spec;
|
|
73
|
-
|
|
74
|
-
const existing = this.material_contexts.get(scratch_mvc);
|
|
75
|
-
|
|
76
|
-
if (existing !== undefined) {
|
|
77
|
-
return existing;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// create a separate instance to be stored alongside the context
|
|
81
|
-
const key = scratch_mvc.clone();
|
|
82
|
-
|
|
83
|
-
const ctx = new MaterialContext(spec, m);
|
|
84
|
-
|
|
85
|
-
ctx.init();
|
|
86
|
-
|
|
87
|
-
this.material_contexts.set(key, ctx);
|
|
88
|
-
this.__contexts_array.push(ctx);
|
|
89
|
-
|
|
90
|
-
this.on.contextAdded.send1(ctx);
|
|
91
|
-
|
|
92
|
-
return ctx;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
44
|
/**
|
|
97
45
|
*
|
|
98
46
|
* @param {THREE.Scene} scene
|
|
99
47
|
*/
|
|
100
48
|
attach(scene) {
|
|
101
49
|
this.__inputs.push(scene);
|
|
102
|
-
this.builder.appendToScene([scene]);
|
|
50
|
+
this.ctx.builder.appendToScene([scene]);
|
|
103
51
|
}
|
|
104
52
|
|
|
105
53
|
attachMany(objects) {
|
|
106
54
|
array_copy(objects, 0, this.__inputs, this.__inputs.length, objects.length);
|
|
107
|
-
this.builder.appendToScene(objects);
|
|
55
|
+
this.ctx.builder.appendToScene(objects);
|
|
108
56
|
}
|
|
109
57
|
|
|
110
58
|
clear() {
|
|
111
59
|
this.__inputs = [];
|
|
112
|
-
this.builder.clearScene();
|
|
60
|
+
this.ctx.builder.clearScene();
|
|
113
61
|
}
|
|
114
62
|
|
|
115
63
|
__prepare_contexts() {
|
|
116
64
|
// clear contexts
|
|
117
|
-
const
|
|
65
|
+
const render_context = this.ctx;
|
|
66
|
+
const contexts = render_context.__contexts_array;
|
|
118
67
|
const context_count = contexts.length;
|
|
119
68
|
|
|
120
69
|
for (let i = 0; i < context_count; i++) {
|
|
@@ -131,7 +80,12 @@ export class VGThreeRenderer {
|
|
|
131
80
|
*/
|
|
132
81
|
const m = o;
|
|
133
82
|
|
|
134
|
-
|
|
83
|
+
scratch_mvc.material = m.material;
|
|
84
|
+
scratch_mvc.spec = m.geometry.vertex_spec;
|
|
85
|
+
scratch_mvc.writeFlag(MaterialVertexSpecFlags.CastShadow, m.castShadow);
|
|
86
|
+
scratch_mvc.writeFlag(MaterialVertexSpecFlags.ReceiveShadow, m.receiveShadow);
|
|
87
|
+
|
|
88
|
+
const ctx = render_context.obtain_material(scratch_mvc);
|
|
135
89
|
|
|
136
90
|
ctx.instances.add(o.instance_id);
|
|
137
91
|
}
|
|
@@ -149,54 +103,7 @@ export class VGThreeRenderer {
|
|
|
149
103
|
}
|
|
150
104
|
|
|
151
105
|
render() {
|
|
152
|
-
|
|
153
|
-
const context_count = contexts.length;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
*
|
|
157
|
-
* @type {Map<number, MaterialContext>}
|
|
158
|
-
*/
|
|
159
|
-
const instance_to_ctx = new Map();
|
|
160
|
-
|
|
161
|
-
for (let i = 0; i < context_count; i++) {
|
|
162
|
-
const ctx = contexts[i];
|
|
163
|
-
ctx.__patch_count = 0;
|
|
164
|
-
|
|
165
|
-
for (const instance of ctx.instances) {
|
|
166
|
-
instance_to_ctx.set(instance, ctx);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// sort patches into relevant contexts
|
|
171
|
-
const geometry = this.geometry;
|
|
172
|
-
const patch_count = geometry.patch_count;
|
|
173
|
-
const patches = geometry.patches;
|
|
174
|
-
|
|
175
|
-
for (let i = 0; i < patch_count; i++) {
|
|
176
|
-
const i3 = i * 3;
|
|
177
|
-
|
|
178
|
-
const instance_id = patches[i3];
|
|
179
|
-
const geometry_id = patches[i3 + 1];
|
|
180
|
-
const patch_id = patches[i3 + 2];
|
|
181
|
-
|
|
182
|
-
const ctx = instance_to_ctx.get(instance_id);
|
|
183
|
-
|
|
184
|
-
const target_address = ctx.__patch_count * 3;
|
|
185
|
-
ctx.__patch_count++;
|
|
186
|
-
|
|
187
|
-
const ctx_patches = ctx.__patches;
|
|
188
|
-
|
|
189
|
-
ctx_patches[target_address] = instance_id;
|
|
190
|
-
ctx_patches[target_address + 1] = geometry_id;
|
|
191
|
-
ctx_patches[target_address + 2] = patch_id;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// build each context
|
|
195
|
-
for (let i = 0; i < context_count; i++) {
|
|
196
|
-
const ctx = contexts[i];
|
|
197
|
-
|
|
198
|
-
ctx.build(this.geometry);
|
|
199
|
-
}
|
|
106
|
+
this.ctx.render();
|
|
200
107
|
}
|
|
201
108
|
|
|
202
109
|
|
|
@@ -224,11 +131,11 @@ export class VGThreeRenderer {
|
|
|
224
131
|
pixelRatio = renderer.getPixelRatio();
|
|
225
132
|
}
|
|
226
133
|
|
|
227
|
-
const vg_builder = this.builder;
|
|
134
|
+
const vg_builder = this.ctx.builder;
|
|
228
135
|
|
|
229
136
|
vg_builder.resolution.set(resolution.x * pixelRatio, resolution.y * pixelRatio);
|
|
230
137
|
vg_builder.setMatricesFromCamera(camera);
|
|
231
|
-
vg_builder.setOutput(this.geometry);
|
|
138
|
+
vg_builder.setOutput(this.ctx.geometry);
|
|
232
139
|
|
|
233
140
|
vg_builder.build();
|
|
234
141
|
}
|
|
@@ -436,7 +436,7 @@ class Path {
|
|
|
436
436
|
*/
|
|
437
437
|
sample_linear(result, offset) {
|
|
438
438
|
|
|
439
|
-
const found = this.
|
|
439
|
+
const found = this.find_index_and_normalized_distance(scratch_array_0, offset);
|
|
440
440
|
|
|
441
441
|
if (!found) {
|
|
442
442
|
return false;
|
|
@@ -466,9 +466,8 @@ class Path {
|
|
|
466
466
|
* @param {number[]} result
|
|
467
467
|
* @param {number} absolute_distance absolute distance along the path
|
|
468
468
|
* @returns {boolean}
|
|
469
|
-
* @private
|
|
470
469
|
*/
|
|
471
|
-
|
|
470
|
+
find_index_and_normalized_distance(result, absolute_distance) {
|
|
472
471
|
const pointCount = this.getPointCount();
|
|
473
472
|
|
|
474
473
|
if (pointCount === 0) {
|
|
@@ -495,10 +494,10 @@ class Path {
|
|
|
495
494
|
// we found v1
|
|
496
495
|
const local_offset = absolute_distance - cursor;
|
|
497
496
|
|
|
498
|
-
const
|
|
497
|
+
const local_normalized_offset = local_offset / distance;
|
|
499
498
|
|
|
500
499
|
result[0] = i - 1;
|
|
501
|
-
result[1] =
|
|
500
|
+
result[1] = local_normalized_offset;
|
|
502
501
|
return true;
|
|
503
502
|
}
|
|
504
503
|
|
|
@@ -525,7 +524,7 @@ class Path {
|
|
|
525
524
|
* @returns {boolean}
|
|
526
525
|
*/
|
|
527
526
|
sample_catmull_rom(result, offset) {
|
|
528
|
-
const found = this.
|
|
527
|
+
const found = this.find_index_and_normalized_distance(scratch_array_0, offset);
|
|
529
528
|
|
|
530
529
|
if (!found) {
|
|
531
530
|
return false;
|
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.35.
|
|
8
|
+
"version": "2.35.13",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|