@woosh/meep-engine 2.34.31 → 2.34.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/assert.js +11 -0
- package/core/bvh2/BinaryNode.js +213 -26
- package/core/bvh2/Node.d.ts +3 -0
- package/core/bvh2/aabb3/AABB3.js +4 -3
- package/core/bvh2/aabb3/AABB3Math.js +1 -1
- package/core/bvh2/transform/RotationOptimizer.js +2 -262
- package/core/bvh2/transform/tryRotateSingleNode.js +259 -0
- package/core/collection/list/List.js +0 -34
- package/core/collection/table/DataTypeByteSizes.js +16 -0
- package/core/events/signal/Signal.js +1 -1
- package/engine/Engine.js +5 -0
- package/engine/asset/loaders/ArrayBufferLoader.js +7 -0
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +11 -6
- package/engine/development/performance/AbstractMetric.js +4 -0
- package/engine/development/performance/RingBufferMetric.js +4 -0
- package/engine/ecs/EntityBuilder.js +12 -5
- package/engine/ecs/EntityComponentDataset.js +26 -6
- package/engine/ecs/attachment/AttachmentSystem.js +1 -1
- package/engine/ecs/sockets/AttachmentSockets.js +11 -1
- package/engine/ecs/transform/Transform.js +1 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +16 -3
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +3 -0
- package/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +60 -0
- package/engine/graphics/ecs/mesh-v2/{prototypeShadedGeometry.js → sample/prototypeShadedGeometry.js} +5 -5
- package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +37 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +15 -0
- package/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +2 -0
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +39 -5
- package/engine/graphics/micron/prototypeVirtualGeometry.js +7 -1
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +3 -0
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +23 -0
- package/engine/sound/ecs/emitter/SoundEmitterSystem.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EngineHarness } from "../../../../EngineHarness.js";
|
|
2
|
+
import { ShadedGeometrySystem } from "../ShadedGeometrySystem.js";
|
|
3
|
+
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
4
|
+
import { EngineConfiguration } from "../../../../EngineConfiguration.js";
|
|
5
|
+
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
6
|
+
import { three_object_to_entity_composition } from "../three_object_to_entity_composition.js";
|
|
7
|
+
import { AttachmentSystem } from "../../../../ecs/attachment/AttachmentSystem.js";
|
|
8
|
+
|
|
9
|
+
const eh = new EngineHarness();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {EngineHarness} harness
|
|
14
|
+
* @return {Promise<void>}
|
|
15
|
+
*/
|
|
16
|
+
async function init(harness) {
|
|
17
|
+
const engine = harness.engine;
|
|
18
|
+
|
|
19
|
+
const config = new EngineConfiguration();
|
|
20
|
+
|
|
21
|
+
config.addSystem(new ShadedGeometrySystem(engine));
|
|
22
|
+
config.addSystem(new AttachmentSystem());
|
|
23
|
+
config.addLoader(GameAssetType.ModelGLTF_JSON, new GLTFAssetLoader());
|
|
24
|
+
|
|
25
|
+
await config.apply(engine);
|
|
26
|
+
|
|
27
|
+
eh.initialize().then(main);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {Engine} engine
|
|
33
|
+
*/
|
|
34
|
+
async function main(engine) {
|
|
35
|
+
|
|
36
|
+
const em = engine.entityManager;
|
|
37
|
+
|
|
38
|
+
EngineHarness.buildBasics({
|
|
39
|
+
engine,
|
|
40
|
+
enableWater: false
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const ecd = em.dataset;
|
|
44
|
+
|
|
45
|
+
const asset = await engine.assetManager.promise('moicon/06_04_hapro/08-clickable-assets-new/model.gltf', GameAssetType.ModelGLTF_JSON);
|
|
46
|
+
|
|
47
|
+
const three_object = asset.create();
|
|
48
|
+
|
|
49
|
+
console.time('composition conversion');
|
|
50
|
+
const composition = three_object_to_entity_composition(three_object);
|
|
51
|
+
console.timeEnd('composition conversion');
|
|
52
|
+
|
|
53
|
+
console.time('composition build');
|
|
54
|
+
// console.profile('composition build');
|
|
55
|
+
composition.build(ecd);
|
|
56
|
+
// console.profileEnd('composition build');
|
|
57
|
+
console.timeEnd('composition build');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
init(eh);
|
package/engine/graphics/ecs/mesh-v2/{prototypeShadedGeometry.js → sample/prototypeShadedGeometry.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EngineHarness } from "
|
|
2
|
-
import { ShadedGeometrySystem } from "
|
|
3
|
-
import EntityBuilder from "
|
|
4
|
-
import { Transform } from "
|
|
5
|
-
import { ShadedGeometry } from "
|
|
1
|
+
import { EngineHarness } from "../../../../EngineHarness.js";
|
|
2
|
+
import { ShadedGeometrySystem } from "../ShadedGeometrySystem.d.ts";
|
|
3
|
+
import EntityBuilder from "../../../../ecs/EntityBuilder.d.ts";
|
|
4
|
+
import { Transform } from "../../../../ecs/transform/Transform.d.ts";
|
|
5
|
+
import { ShadedGeometry } from "../ShadedGeometry.d.ts";
|
|
6
6
|
import { BoxBufferGeometry, MeshBasicMaterial } from "three";
|
|
7
7
|
|
|
8
8
|
const eh = new EngineHarness();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EntityNode } from "../../../ecs/parent/EntityNode.js";
|
|
2
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
3
|
+
import { ShadedGeometry } from "./ShadedGeometry.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {THREE.Object3D} root
|
|
8
|
+
* @returns {EntityNode}
|
|
9
|
+
*/
|
|
10
|
+
export function three_object_to_entity_composition(root) {
|
|
11
|
+
const node = new EntityNode();
|
|
12
|
+
|
|
13
|
+
node.transform.fromMatrix4(root.matrix.elements);
|
|
14
|
+
|
|
15
|
+
node.entity.add(new Transform());
|
|
16
|
+
|
|
17
|
+
if (root.isMesh) {
|
|
18
|
+
if (root.isSkinnedMesh) {
|
|
19
|
+
throw new Error(`Skinned meshes are not supported`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
node.entity.add(ShadedGeometry.from(root.geometry, root.material));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const children = root.children;
|
|
26
|
+
const child_count = children.length;
|
|
27
|
+
for (let i = 0; i < child_count; i++) {
|
|
28
|
+
const child = children[i];
|
|
29
|
+
|
|
30
|
+
const child_node = three_object_to_entity_composition(child);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
node.addChild(child_node);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
@@ -51,6 +51,17 @@ function custom_attribute_format_uv(spec, source) {
|
|
|
51
51
|
spec.type = DataType.Float16;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {AttributeSpec} spec
|
|
57
|
+
* @param {THREE.BufferAttribute} source
|
|
58
|
+
*/
|
|
59
|
+
function custom_attribute_format_color(spec, source) {
|
|
60
|
+
// crush color data to 8 bit
|
|
61
|
+
spec.type = DataType.Uint8;
|
|
62
|
+
spec.normalized = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
/**
|
|
55
66
|
*
|
|
56
67
|
* @param {AttributeSpec} spec
|
|
@@ -70,7 +81,11 @@ function format_attribute(spec, source, name) {
|
|
|
70
81
|
case 'normal':
|
|
71
82
|
custom_attribute_format_normal(spec, source);
|
|
72
83
|
break;
|
|
84
|
+
case 'color':
|
|
85
|
+
custom_attribute_format_color(spec, source);
|
|
86
|
+
break;
|
|
73
87
|
default:
|
|
88
|
+
spec.normalized = source.normalized;
|
|
74
89
|
spec.type = typedArrayToDataType(source.array)
|
|
75
90
|
}
|
|
76
91
|
|
|
@@ -9,6 +9,9 @@ import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
|
9
9
|
import { passThrough } from "../../../../core/function/Functions.js";
|
|
10
10
|
import { to_half_float_uint16 } from "../../../../core/binary/to_half_float_uint16.js";
|
|
11
11
|
import { compute_micron_buffer_array_constructor } from "./compute_micron_buffer_array_constructor.js";
|
|
12
|
+
import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
|
|
13
|
+
import { dataTypeByteSize } from "../../../../core/collection/table/DataTypeByteSizes.js";
|
|
14
|
+
import { clamp } from "../../../../core/math/clamp.js";
|
|
12
15
|
|
|
13
16
|
function UintArrayForCount(count) {
|
|
14
17
|
|
|
@@ -90,6 +93,17 @@ function copy_attribute_data(vertex_count, index_map_backward, itemSize, attribu
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param {number} value
|
|
99
|
+
* @returns {number}
|
|
100
|
+
*/
|
|
101
|
+
function resample_normalized_uint16_to_uint8(value) {
|
|
102
|
+
const normalized = clamp(value / 65535, 0, 1);
|
|
103
|
+
|
|
104
|
+
return Math.round(normalized * 255);
|
|
105
|
+
}
|
|
106
|
+
|
|
93
107
|
/**
|
|
94
108
|
*
|
|
95
109
|
* @param {number} value
|
|
@@ -105,7 +119,8 @@ function normalize_to_int8(value) {
|
|
|
105
119
|
const DataConverterType = {
|
|
106
120
|
None: passThrough,
|
|
107
121
|
Number2HalfFloat: to_half_float_uint16,
|
|
108
|
-
Normalize2Int8: normalize_to_int8
|
|
122
|
+
Normalize2Int8: normalize_to_int8,
|
|
123
|
+
ResampleNormalized_Uint16_to_Uint8: resample_normalized_uint16_to_uint8
|
|
109
124
|
};
|
|
110
125
|
|
|
111
126
|
/**
|
|
@@ -115,17 +130,36 @@ const DataConverterType = {
|
|
|
115
130
|
* @returns {DataConverterType}
|
|
116
131
|
*/
|
|
117
132
|
function compute_attribute_data_converter(source, spec) {
|
|
118
|
-
|
|
133
|
+
const target_type = spec.type;
|
|
134
|
+
if (target_type === DataType.Float16) {
|
|
119
135
|
return DataConverterType.Number2HalfFloat;
|
|
120
136
|
} else if (spec.normalized && !source.normalized) {
|
|
121
137
|
// source data can be normalized but isn't
|
|
122
|
-
if (
|
|
138
|
+
if (target_type === DataType.Int8) {
|
|
123
139
|
return DataConverterType.Normalize2Int8;
|
|
124
140
|
} else {
|
|
125
|
-
throw new Error(`Unsupported normalized type '${
|
|
141
|
+
throw new Error(`Unsupported normalized type '${target_type}'`);
|
|
126
142
|
}
|
|
127
143
|
} else {
|
|
128
|
-
|
|
144
|
+
const source_array = source.array;
|
|
145
|
+
|
|
146
|
+
const source_type = typedArrayToDataType(source_array);
|
|
147
|
+
|
|
148
|
+
const target_byte_size = dataTypeByteSize(target_type);
|
|
149
|
+
const source_byte_size = dataTypeByteSize(source_type)
|
|
150
|
+
|
|
151
|
+
if (target_byte_size !== source_byte_size) {
|
|
152
|
+
// wrong data size
|
|
153
|
+
|
|
154
|
+
if (target_type === DataType.Uint8 && source_type === DataType.Uint16) {
|
|
155
|
+
return DataConverterType.ResampleNormalized_Uint16_to_Uint8;
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error(`Unsupported conversion ${source_type} -> ${target_type}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
} else {
|
|
161
|
+
return DataConverterType.None;
|
|
162
|
+
}
|
|
129
163
|
}
|
|
130
164
|
}
|
|
131
165
|
|
|
@@ -455,7 +455,7 @@ function init() {
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
// sample_gltf_sponza();
|
|
458
|
-
gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
|
|
458
|
+
// gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
|
|
459
459
|
// sample_lucy();
|
|
460
460
|
// sample_gltf_hapro_2();
|
|
461
461
|
// sample_gltf_hapro_1();
|
|
@@ -468,6 +468,12 @@ function init() {
|
|
|
468
468
|
// gltf_sample('moicon/29_Dec_2021_Nammo/1/model.gltf');
|
|
469
469
|
// gltf_sample('moicon/29_Dec_2021_Nammo/1-onematerial/model.gltf');
|
|
470
470
|
// gltf_sample('moicon/29_Dec_2021_Nammo/2/model.gltf');
|
|
471
|
+
// gltf_sample('moicon/03_Jan_22_Demo/1-ground_floor/model.gltf');
|
|
472
|
+
// gltf_sample('moicon/03_Jan_22_Demo/2-1st_floor/model.gltf');
|
|
473
|
+
// gltf_sample('moicon/03_Jan_22_Demo/3-area_ground_floor/model.gltf');
|
|
474
|
+
// gltf_sample('moicon/03_Jan_22_Demo/4-area_1st_floor/model.gltf');
|
|
475
|
+
// gltf_sample('moicon/03_Jan_22_Demo/8-assets/model.gltf');
|
|
476
|
+
gltf_sample('moicon/03_Jan_22_Demo/worker_test/model.gltf');
|
|
471
477
|
|
|
472
478
|
document.addEventListener("mousemove", onDocumentMouseMove);
|
|
473
479
|
|
|
@@ -160,6 +160,29 @@ export function shader_rewrite_standard(shader, uniforms, spec, column_count) {
|
|
|
160
160
|
|
|
161
161
|
if (attribute_spec_color !== undefined) {
|
|
162
162
|
// using color
|
|
163
|
+
const vx_color_value = `texelFetch(${gen_micron_vertex_attribute_texture_name('color')}, micron_vertex_uv, 0)`
|
|
164
|
+
|
|
165
|
+
rewrittenVertexShader = rewrittenVertexShader.replace(
|
|
166
|
+
'#include <color_vertex>',
|
|
167
|
+
`
|
|
168
|
+
#if defined( USE_COLOR_ALPHA )
|
|
169
|
+
vColor = vec4( 1.0 );
|
|
170
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
171
|
+
vColor = vec3( 1.0 );
|
|
172
|
+
#endif
|
|
173
|
+
|
|
174
|
+
#ifdef USE_COLOR
|
|
175
|
+
|
|
176
|
+
#ifdef USE_COLOR_ALPHA
|
|
177
|
+
vColor *= ${vx_color_value}.rgba;
|
|
178
|
+
#else
|
|
179
|
+
vColor *= ${vx_color_value}.rgb;
|
|
180
|
+
#endif
|
|
181
|
+
|
|
182
|
+
#endif
|
|
183
|
+
|
|
184
|
+
`
|
|
185
|
+
);
|
|
163
186
|
|
|
164
187
|
}
|
|
165
188
|
|
|
@@ -14,11 +14,11 @@ import { BinaryNode } from "../../../../core/bvh2/BinaryNode.js";
|
|
|
14
14
|
import SoundListener from "../SoundListener.js";
|
|
15
15
|
import { IncrementalDeltaSet } from "../../../graphics/render/visibility/IncrementalDeltaSet.js";
|
|
16
16
|
import { queryBinaryNode_SphereIntersections_Data } from "../../../../core/bvh2/traversal/queryBinaryNode_SphereIntersections.js";
|
|
17
|
-
import { tryRotateSingleNode } from "../../../../core/bvh2/transform/RotationOptimizer.js";
|
|
18
17
|
import { SoundEmitterComponentContext } from "./SoundEmitterComponentContext.js";
|
|
19
18
|
import { SoundEmitterFlags } from "./SoundEmitterFlags.js";
|
|
20
19
|
import { SoundEmitterChannel } from "./SoundEmitterChannel.js";
|
|
21
20
|
import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
|
|
21
|
+
import { tryRotateSingleNode } from "../../../../core/bvh2/transform/tryRotateSingleNode.js";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @readonly
|
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.34.
|
|
8
|
+
"version": "2.34.35",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|