@woosh/meep-engine 2.63.0 → 2.65.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/build/meep.cjs +5357 -5350
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +5357 -5350
- package/package.json +1 -1
- package/src/core/binary/UINT16_MAX.js +5 -0
- package/src/core/bvh2/BinaryNode.js +14 -14
- package/src/core/bvh2/LeafNode.js +4 -4
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.d.ts → BVH.d.ts} +1 -1
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.js → BVH.js} +7 -7
- package/src/core/bvh2/bvh3/{ExplicitBinaryBoundingVolumeHierarchy.spec.js → BVH.spec.js} +20 -20
- package/src/core/bvh2/bvh3/{EBBVHLeafProxy.js → BvhClient.js} +3 -3
- package/src/core/bvh2/bvh3/BvhClient.spec.js +51 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +2 -2
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +4 -4
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +2 -8
- package/src/core/bvh2/bvh3/query/BVHQuery.js +1 -1
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +3 -8
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +13 -5
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +3 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.spec.js +3 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +3 -3
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +4 -4
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.spec.js +3 -3
- package/src/core/collection/list/List.js +9 -3
- package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
- package/src/core/geom/Vector2.js +6 -4
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +22 -24
- package/src/engine/graphics/ecs/mesh/Mesh.js +8 -8
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +3 -5
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -6
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +3 -3
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +16 -18
- package/src/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +5 -5
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +9 -11
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +51 -88
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
- package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
- package/src/engine/graphics/render/forward_plus/LightManager.js +30 -32
- package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +3 -3
- package/src/engine/graphics/sh3/LightProbeVolume.js +19 -19
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +4 -6
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +17 -19
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +18 -16
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +20 -22
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
- package/src/engine/ecs/foliage/Foliage.js +0 -151
- package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
- package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
- package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
- package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
- package/src/engine/ecs/foliage/ViewState.js +0 -181
- package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
- package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
- package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
- package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
- package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
- package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
- package/src/engine/save/storage/GooglePlayStorage.js +0 -47
- package/src/engine/save/storage/JsonStringCodec.js +0 -24
- /package/src/engine/sound/ecs/emitter/{SoundEmitter.spec.js → SoundEmitterSerializationAdapter.spec.js} +0 -0
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import {buildTreeOptimizationTask} from "../../../../core/bvh2/BVHTasks.js";
|
|
2
|
-
import Task from "../../../../core/process/task/Task.js";
|
|
3
|
-
import {TaskSignal} from "../../../../core/process/task/TaskSignal.js";
|
|
4
|
-
import {countTask} from "../../../../core/process/task/util/countTask.js";
|
|
5
|
-
import {promiseTask} from "../../../../core/process/task/util/promiseTask.js";
|
|
6
|
-
import Mesh, {MeshFlags} from "../../../graphics/ecs/mesh/Mesh.js";
|
|
7
|
-
import Entity from "../../Entity.js";
|
|
8
|
-
import {Transform} from "../../transform/Transform.js";
|
|
9
|
-
import {InstancedFoliage} from "../InstancedFoliage.js";
|
|
10
|
-
import {InstancedMeshComponent} from "./InstancedMeshComponent.js";
|
|
11
|
-
import {InstancedMeshLayer} from "./InstancedMeshLayer.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {EntityComponentDataset} dataset
|
|
16
|
-
* @param {number} threshold minimum number of instances required before conversion happens
|
|
17
|
-
* @returns {{main:Task, tasks:Task[]}}
|
|
18
|
-
*/
|
|
19
|
-
export function optimizeIndividualMeshesEntitiesToInstances(dataset, threshold = 30) {
|
|
20
|
-
//get all entities that have a translation and mesh only
|
|
21
|
-
const candidates = {};
|
|
22
|
-
const not_loaded = {};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {Mesh} mesh
|
|
27
|
-
* @param {Transform} transform
|
|
28
|
-
* @param {int} entity
|
|
29
|
-
*/
|
|
30
|
-
function visitMeshTransformEntity(mesh, transform, entity) {
|
|
31
|
-
const model_url = mesh.url;
|
|
32
|
-
|
|
33
|
-
if (model_url === undefined || model_url === null || model_url.trim().length === 0) {
|
|
34
|
-
//not a valid URL
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (mesh.getFlag(MeshFlags.Loaded) && (mesh.mesh.isMesh !== true || mesh.mesh.isSkinnedMesh === true)) {
|
|
39
|
-
// mesh is not compatible with instancing
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!mesh.getFlag(MeshFlags.Loaded)) {
|
|
44
|
-
let misses = not_loaded[model_url];
|
|
45
|
-
|
|
46
|
-
if (misses === undefined) {
|
|
47
|
-
misses = not_loaded[model_url] = [];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
misses.push(entity);
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let list;
|
|
56
|
-
if (!candidates.hasOwnProperty(model_url)) {
|
|
57
|
-
list = [];
|
|
58
|
-
candidates[model_url] = {
|
|
59
|
-
mesh,
|
|
60
|
-
list
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
list = candidates[model_url].list;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
list.push({
|
|
67
|
-
entity,
|
|
68
|
-
position: transform.position,
|
|
69
|
-
rotation: transform.rotation,
|
|
70
|
-
scale: transform.scale
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// traverse entities that have only Mesh and a Transform
|
|
75
|
-
dataset.traverseEntitiesExact([Mesh, Transform], visitMeshTransformEntity);
|
|
76
|
-
|
|
77
|
-
for (const mesh_url in not_loaded) {
|
|
78
|
-
|
|
79
|
-
console.warn(`Mesh[${mesh_url}] not loaded, ${not_loaded[mesh_url].length} entities affected`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const tasks = [];
|
|
83
|
-
|
|
84
|
-
const foliage2 = new InstancedMeshComponent();
|
|
85
|
-
|
|
86
|
-
const tBuild = new Task({
|
|
87
|
-
name: "Build Meshes",
|
|
88
|
-
cycleFunction: function () {
|
|
89
|
-
const entityBuilder = new Entity();
|
|
90
|
-
|
|
91
|
-
entityBuilder.add(foliage2);
|
|
92
|
-
|
|
93
|
-
entityBuilder.build(dataset);
|
|
94
|
-
|
|
95
|
-
return TaskSignal.EndSuccess;
|
|
96
|
-
},
|
|
97
|
-
computeProgress: function () {
|
|
98
|
-
return 1;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
tasks.push(tBuild);
|
|
103
|
-
|
|
104
|
-
let modelURL;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
function createLayerForInstances(group, modelURL) {
|
|
108
|
-
const instances = group.list;
|
|
109
|
-
const numInstances = instances.length;
|
|
110
|
-
|
|
111
|
-
if (numInstances < threshold) {
|
|
112
|
-
//too new instances to convert
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
//build up instanced mesh
|
|
117
|
-
const instancedFoliage = new InstancedFoliage();
|
|
118
|
-
|
|
119
|
-
const tLoadGeometry = promiseTask(new Promise(function (resolve, reject) {
|
|
120
|
-
|
|
121
|
-
const mesh = group.mesh.mesh;
|
|
122
|
-
const geometry = mesh.geometry;
|
|
123
|
-
|
|
124
|
-
instancedFoliage.setInstance(geometry, mesh.material);
|
|
125
|
-
|
|
126
|
-
resolve();
|
|
127
|
-
}), 'Loading Instance Geometry');
|
|
128
|
-
|
|
129
|
-
tasks.push(tLoadGeometry);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const tPopulate = countTask(0, numInstances, function (i) {
|
|
133
|
-
const instance = instances[i];
|
|
134
|
-
|
|
135
|
-
//check for 0 scale
|
|
136
|
-
if (instance.scale.isZero()) {
|
|
137
|
-
//ignore an instance with 0 scale, it is not visible.
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//check for duplicates before
|
|
142
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
143
|
-
|
|
144
|
-
const instanceTemp = instances[j];
|
|
145
|
-
|
|
146
|
-
if (instance.position.equals(instanceTemp.position) && instance.rotation.equals(instanceTemp.rotation) && instance.scale.equals(instanceTemp.scale)) {
|
|
147
|
-
//identical instance was found in the past, skip
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
instancedFoliage.add(instance.position, instance.rotation, instance.scale);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
tPopulate.addDependency(tLoadGeometry);
|
|
156
|
-
|
|
157
|
-
tPopulate.name = `Populate instanced of '${modelURL}'`;
|
|
158
|
-
|
|
159
|
-
tasks.push(tPopulate);
|
|
160
|
-
|
|
161
|
-
//
|
|
162
|
-
const tOptimization = buildTreeOptimizationTask(instancedFoliage.bvh, instancedFoliage.data.length * 4);
|
|
163
|
-
tOptimization.addDependency(tPopulate);
|
|
164
|
-
|
|
165
|
-
tasks.push(tOptimization);
|
|
166
|
-
|
|
167
|
-
const tGenerateLayer = new Task({
|
|
168
|
-
name: "Serialize data",
|
|
169
|
-
cycleFunction: function () {
|
|
170
|
-
|
|
171
|
-
//create foliage layer
|
|
172
|
-
const layer = new InstancedMeshLayer();
|
|
173
|
-
|
|
174
|
-
layer.data = instancedFoliage;
|
|
175
|
-
layer.modelURL.set(modelURL);
|
|
176
|
-
|
|
177
|
-
//TODO shadow settings are just assumptions
|
|
178
|
-
layer.castShadow.set(true);
|
|
179
|
-
layer.receiveShadow.set(true);
|
|
180
|
-
|
|
181
|
-
instancedFoliage.castShadow = layer.castShadow.getValue();
|
|
182
|
-
instancedFoliage.receiveShadow = layer.receiveShadow.getValue();
|
|
183
|
-
|
|
184
|
-
foliage2.layers.add(layer);
|
|
185
|
-
|
|
186
|
-
return TaskSignal.EndSuccess;
|
|
187
|
-
},
|
|
188
|
-
computeProgress: function () {
|
|
189
|
-
return 1;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
tGenerateLayer.addDependency(tOptimization);
|
|
194
|
-
|
|
195
|
-
tasks.push(tGenerateLayer);
|
|
196
|
-
|
|
197
|
-
//make layer building task a dependency to the main task
|
|
198
|
-
tBuild.addDependency(tGenerateLayer);
|
|
199
|
-
|
|
200
|
-
//make a task to destroy original entities
|
|
201
|
-
const tCleanup = countTask(0, numInstances, function (i) {
|
|
202
|
-
const instance = instances[i];
|
|
203
|
-
|
|
204
|
-
const entity = instance.entity;
|
|
205
|
-
|
|
206
|
-
dataset.removeEntity(entity);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
tCleanup.name = `Remove Original Instances of '${modelURL}'`;
|
|
210
|
-
|
|
211
|
-
tCleanup.addDependency(tBuild);
|
|
212
|
-
|
|
213
|
-
tasks.push(tCleanup);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
for (modelURL in candidates) {
|
|
217
|
-
|
|
218
|
-
if (!candidates.hasOwnProperty(modelURL)) {
|
|
219
|
-
//by some black magic - the candidates don't have this modelURL. This is a sanity check
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const instances = candidates[modelURL];
|
|
224
|
-
|
|
225
|
-
createLayerForInstances(instances, modelURL);
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
main: tBuild,
|
|
231
|
-
tasks
|
|
232
|
-
};
|
|
233
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 22/02/2017.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import Storage from '../Storage.js';
|
|
6
|
-
|
|
7
|
-
class GooglePlayStorage extends Storage {
|
|
8
|
-
constructor(gapi) {
|
|
9
|
-
super();
|
|
10
|
-
if (typeof gapi.client.games !== "object") {
|
|
11
|
-
gapi.client.load('games', 'v1', function (response) {
|
|
12
|
-
console.log('loaded google games API');
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
this.api = gapi;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
store(key, value, resolve, reject, progress) {
|
|
19
|
-
this.api.client.request({
|
|
20
|
-
path: '/games/v1/snapshots',
|
|
21
|
-
params: {
|
|
22
|
-
snapshotId: key
|
|
23
|
-
},
|
|
24
|
-
method: "put",
|
|
25
|
-
body: value
|
|
26
|
-
}).then(function (r) {
|
|
27
|
-
console.log(r);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
load(key, resolve, reject, progress) {
|
|
32
|
-
this.api.client.games.snapshots.get(key, function (r) {
|
|
33
|
-
console.log("Snapshot loaded", r);
|
|
34
|
-
resolve(r);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
list(keyRead) {
|
|
39
|
-
this.api.client.games.snapshots.list({
|
|
40
|
-
playerId: "me"
|
|
41
|
-
}, function (r) {
|
|
42
|
-
console.log("Snapshot list obtained", r);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default GooglePlayStorage;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 12/06/2017.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { stringify } from "../../../core/json/JsonUtils.js";
|
|
7
|
-
import {byteArrayToString} from "../../../core/binary/byteArrayToString.js";
|
|
8
|
-
|
|
9
|
-
function JsonStringCodec() {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
JsonStringCodec.prototype.encode = function (json) {
|
|
13
|
-
console.time("stringification of value");
|
|
14
|
-
const saveString = stringify(json);
|
|
15
|
-
console.timeEnd("stringification of value");
|
|
16
|
-
return saveString;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
JsonStringCodec.prototype.decode = function (bytes) {
|
|
20
|
-
const stringValue = byteArrayToString(bytes);
|
|
21
|
-
return JSON.parse(stringValue);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default JsonStringCodec;
|
|
File without changes
|