@woosh/meep-engine 2.33.56 → 2.33.60
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/aabb3/AABB3.js +4 -1
- package/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +6 -6
- package/core/cache/Cache.js +7 -0
- package/core/collection/array/fastArrayEquals.js +17 -0
- package/core/collection/array/typed/is_typed_array_equals.js +58 -0
- package/core/collection/map/AbstractAsyncMap.js +30 -0
- package/core/collection/map/AsyncMapWrapper.js +16 -0
- package/core/collection/map/AsyncRemoteHashMap.js +358 -0
- package/core/collection/map/CachedAsyncMap.js +34 -0
- package/core/geom/Vector4.js +5 -5
- package/engine/animation/removeEntityGenericEffect.js +22 -31
- package/engine/asset/Asset.js +0 -45
- package/engine/asset/AssetDescription.js +51 -0
- package/engine/asset/AssetManager.d.ts +7 -0
- package/engine/asset/AssetManager.js +98 -2
- package/engine/asset/AssetTransformer.d.ts +5 -0
- package/engine/asset/AssetTransformer.js +15 -0
- package/engine/asset/loaders/GLTFAssetLoader.js +27 -25
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +2 -2
- package/engine/asset/loaders/material/computeTextureEquality.js +2 -2
- package/engine/ecs/gui/GUIElement.js +0 -106
- package/engine/ecs/gui/GUIElementSerializationAdapter.js +108 -0
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +60 -45
- package/engine/ecs/storage/binary/BinaryClassUpgrader.js +1 -0
- package/engine/ecs/util/removeComponentsExcept.js +3 -3
- package/engine/graphics/GraphicsEngine.js +3 -3
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +0 -1
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.spec.js +8 -0
- package/engine/graphics/ecs/mesh/Mesh.js +5 -5
- package/engine/graphics/ecs/mesh/MeshSystem.js +12 -20
- package/engine/graphics/ecs/path/PathDisplaySystem.d.ts +3 -1
- package/engine/graphics/ecs/trail2d/Trail2D.js +35 -1
- package/engine/graphics/ecs/trail2d/Trail2DSystem.js +26 -19
- package/engine/graphics/ecs/trail2d/makeGradientTrail.js +68 -0
- package/engine/graphics/micron/convert_three_object_to_micron.js +24 -7
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -4
- package/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +176 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -2
- package/engine/graphics/render/buffer/simple-fx/DepthLimitedBlur.js +2 -2
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
- package/engine/graphics/render/buffer/simple-fx/ao/SAOShader.js +9 -15
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -0
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +3 -1
- package/engine/graphics/shadows/ShadowMapRenderer.js +10 -4
- package/engine/graphics/texture/sampler/Sampler2D.js +24 -45
- package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +3 -0
- package/engine/save/storage/IndexedDBStorage.js +8 -1
- package/package.json +1 -1
|
@@ -3,6 +3,57 @@ import { VGThreeRenderer } from "../render/v1/VGThreeRenderer.js";
|
|
|
3
3
|
import { RenderLayer } from "../../render/layers/RenderLayer.js";
|
|
4
4
|
import { RenderPassType } from "../../render/RenderPassType.js";
|
|
5
5
|
import { SOURCE_RENDER_LAYER_PROPERTY } from "../../render/visibility/VisibilityComputer.js";
|
|
6
|
+
import { AssetTransformer } from "../../../asset/AssetTransformer.js";
|
|
7
|
+
import { convert_three_object_to_micron } from "../convert_three_object_to_micron.js";
|
|
8
|
+
import { Cache } from "../../../../core/cache/Cache.js";
|
|
9
|
+
import { computeGeometryHash } from "../../../asset/loaders/geometry/geometry/computeGeometryHash.js";
|
|
10
|
+
import { computeGeometryEquality } from "../../../asset/loaders/geometry/geometry/computeGeometryEquality.js";
|
|
11
|
+
import { CachedAsyncMap } from "../../../../core/collection/map/CachedAsyncMap.js";
|
|
12
|
+
import { AsyncRemoteHashMap } from "../../../../core/collection/map/AsyncRemoteHashMap.js";
|
|
13
|
+
import { BufferGeometrySerializationAdapter } from "./serialization/BufferGeometrySerializationAdapter.js";
|
|
14
|
+
import { MicronGeometryBinarySerializationAdapter } from "../format/serialization/MicronGeometryBinarySerializationAdapter.js";
|
|
15
|
+
import { AsyncMapWrapper } from "../../../../core/collection/map/AsyncMapWrapper.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
const STORAGE_KEY = '@plugin/virtual-geometry-micron/geometry-cache';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class GLTFAssetTransformer extends AssetTransformer {
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>} cache
|
|
28
|
+
*/
|
|
29
|
+
constructor(cache) {
|
|
30
|
+
super();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
this.__cache = cache;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async transform(source) {
|
|
41
|
+
const animationClips = source.animations;
|
|
42
|
+
if (animationClips !== undefined && animationClips.length > 0) {
|
|
43
|
+
// not suitable
|
|
44
|
+
return source;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const root = source.create();
|
|
48
|
+
|
|
49
|
+
const micron_root = await convert_three_object_to_micron(root.clone(), this.__cache);
|
|
50
|
+
micron_root.boundingSphere = root.boundingSphere;
|
|
51
|
+
|
|
52
|
+
source.override_mesh = micron_root;
|
|
53
|
+
|
|
54
|
+
return source;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
6
57
|
|
|
7
58
|
export class MicronRenderPlugin extends EnginePlugin {
|
|
8
59
|
constructor() {
|
|
@@ -37,6 +88,40 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
37
88
|
});
|
|
38
89
|
|
|
39
90
|
this.__view_observers = new Map();
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @type {AsyncRemoteHashMap}
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
this.__persisted_geometry = new AsyncRemoteHashMap({
|
|
98
|
+
keyHashFunction: computeGeometryHash,
|
|
99
|
+
keyEqualityFunction: computeGeometryEquality,
|
|
100
|
+
keySerializationAdapter: new BufferGeometrySerializationAdapter(),
|
|
101
|
+
valueSerializationAdapter: new MicronGeometryBinarySerializationAdapter(),
|
|
102
|
+
storageKeyPrefix: STORAGE_KEY,
|
|
103
|
+
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
this.__cache = new CachedAsyncMap(
|
|
111
|
+
new AsyncMapWrapper(new Cache({
|
|
112
|
+
keyHashFunction: computeGeometryHash,
|
|
113
|
+
keyEqualityFunction: computeGeometryEquality
|
|
114
|
+
})),
|
|
115
|
+
this.__persisted_geometry
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @type {AssetTransformer}
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
this.__asset_transformer = new GLTFAssetTransformer(this.__cache);
|
|
124
|
+
|
|
40
125
|
}
|
|
41
126
|
|
|
42
127
|
/**
|
|
@@ -87,13 +172,22 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
87
172
|
view.on.preRender.remove(observer);
|
|
88
173
|
}
|
|
89
174
|
|
|
175
|
+
__ingest_cache() {
|
|
176
|
+
this.engine.storage.lo
|
|
177
|
+
}
|
|
178
|
+
|
|
90
179
|
async startup() {
|
|
91
180
|
|
|
181
|
+
const engine = this.engine;
|
|
182
|
+
|
|
183
|
+
engine.assetManager.registerTransformer("model/gltf", this.__asset_transformer);
|
|
184
|
+
engine.assetManager.registerTransformer("model/gltf+json", this.__asset_transformer);
|
|
185
|
+
|
|
92
186
|
/**
|
|
93
187
|
*
|
|
94
188
|
* @type {GraphicsEngine}
|
|
95
189
|
*/
|
|
96
|
-
const ge =
|
|
190
|
+
const ge = engine.graphics;
|
|
97
191
|
|
|
98
192
|
ge.layers.add(this.__micron_render_layer);
|
|
99
193
|
|
|
@@ -101,13 +195,22 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
101
195
|
ge.views.elements.on.removed.add(this.__handle_view_removed, this);
|
|
102
196
|
|
|
103
197
|
// link all views
|
|
104
|
-
ge.views.elements.forEach(this.__handle_view_added,this);
|
|
198
|
+
ge.views.elements.forEach(this.__handle_view_added, this);
|
|
199
|
+
|
|
200
|
+
this.__persisted_geometry.attach_storage(engine.storage);
|
|
105
201
|
|
|
106
202
|
await super.startup();
|
|
107
203
|
}
|
|
108
204
|
|
|
109
205
|
async shutdown() {
|
|
110
|
-
const
|
|
206
|
+
const engine = this.engine;
|
|
207
|
+
|
|
208
|
+
this.__persisted_geometry.detach_storage();
|
|
209
|
+
|
|
210
|
+
engine.assetManager.unregisterTransformer("model/gltf", this.__asset_transformer);
|
|
211
|
+
engine.assetManager.unregisterTransformer("model/gltf+json", this.__asset_transformer);
|
|
212
|
+
|
|
213
|
+
const ge = engine.graphics;
|
|
111
214
|
|
|
112
215
|
ge.layers.remove(this.__micron_render_layer);
|
|
113
216
|
|
|
@@ -115,7 +218,7 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
115
218
|
ge.views.elements.on.removed.remove(this.__handle_view_removed, this);
|
|
116
219
|
|
|
117
220
|
// clear all observer
|
|
118
|
-
ge.views.elements.forEach(this.__handle_view_removed,this);
|
|
221
|
+
ge.views.elements.forEach(this.__handle_view_removed, this);
|
|
119
222
|
|
|
120
223
|
await super.shutdown();
|
|
121
224
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { BufferAttribute, BufferGeometry } from "three";
|
|
3
|
+
|
|
4
|
+
function typed_array_to_enum(array) {
|
|
5
|
+
if (array instanceof Uint8Array) {
|
|
6
|
+
return 0;
|
|
7
|
+
} else if (array instanceof Uint16Array) {
|
|
8
|
+
return 1;
|
|
9
|
+
} else if (array instanceof Uint32Array) {
|
|
10
|
+
return 2;
|
|
11
|
+
} else if (array instanceof Uint8Array) {
|
|
12
|
+
return 3;
|
|
13
|
+
} else if (array instanceof Uint16Array) {
|
|
14
|
+
return 4;
|
|
15
|
+
} else if (array instanceof Uint32Array) {
|
|
16
|
+
return 5;
|
|
17
|
+
} else if (array instanceof Float32Array) {
|
|
18
|
+
return 6;
|
|
19
|
+
} else if (array instanceof Float64Array) {
|
|
20
|
+
return 7;
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error('Unsupported array type');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function marker_to_typed_array_constructor(marker) {
|
|
27
|
+
switch (marker) {
|
|
28
|
+
case 0:
|
|
29
|
+
return Uint8Array;
|
|
30
|
+
case 1:
|
|
31
|
+
return Uint16Array;
|
|
32
|
+
case 2:
|
|
33
|
+
return Uint32Array;
|
|
34
|
+
case 3:
|
|
35
|
+
return Int8Array;
|
|
36
|
+
case 4:
|
|
37
|
+
return Int16Array;
|
|
38
|
+
case 5:
|
|
39
|
+
return Int32Array;
|
|
40
|
+
case 6:
|
|
41
|
+
return Float32Array;
|
|
42
|
+
case 7:
|
|
43
|
+
return Float64Array;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error('Unsupported marker');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {BinaryBuffer} buffer
|
|
52
|
+
* @param {Uint8Array|Float32Array|ArrayLike<number>} value
|
|
53
|
+
*/
|
|
54
|
+
function write_typed_array(buffer, value) {
|
|
55
|
+
|
|
56
|
+
buffer.writeUint8(typed_array_to_enum(value));
|
|
57
|
+
buffer.writeUintVar(value.byteLength);
|
|
58
|
+
|
|
59
|
+
const data = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
60
|
+
buffer.writeBytes(data, 0, value.byteLength);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function read_typed_array(buffer) {
|
|
64
|
+
const type_marker = buffer.readUint8();
|
|
65
|
+
const byte_length = buffer.readUintVar();
|
|
66
|
+
|
|
67
|
+
const array = new Uint8Array(byte_length);
|
|
68
|
+
|
|
69
|
+
buffer.readBytes(array, 0, byte_length);
|
|
70
|
+
|
|
71
|
+
// re-interpret bytes
|
|
72
|
+
const TypedArray = marker_to_typed_array_constructor(type_marker);
|
|
73
|
+
|
|
74
|
+
return new TypedArray(array.buffer, 0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {BinaryBuffer} buffer
|
|
80
|
+
* @param {BufferAttribute} value
|
|
81
|
+
*/
|
|
82
|
+
function write_attribute(buffer, value) {
|
|
83
|
+
buffer.writeUTF8String(value.name);
|
|
84
|
+
buffer.writeUintVar(value.itemSize);
|
|
85
|
+
buffer.writeUint8(value.normalized ? 1 : 0);
|
|
86
|
+
buffer.writeUint32(value.usage);
|
|
87
|
+
|
|
88
|
+
write_typed_array(buffer, value.array);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param {BinaryBuffer} buffer
|
|
94
|
+
* @returns {BufferAttribute}
|
|
95
|
+
*/
|
|
96
|
+
function read_attribute(buffer) {
|
|
97
|
+
const name = buffer.readUTF8String();
|
|
98
|
+
const itemSize = buffer.readUintVar();
|
|
99
|
+
const normalized = buffer.readUint8() !== 0;
|
|
100
|
+
const usage = buffer.readUint32();
|
|
101
|
+
|
|
102
|
+
const array = read_typed_array(buffer);
|
|
103
|
+
|
|
104
|
+
const attribute = new BufferAttribute(array, itemSize, normalized);
|
|
105
|
+
|
|
106
|
+
attribute.usage = usage;
|
|
107
|
+
attribute.name = name;
|
|
108
|
+
|
|
109
|
+
return attribute;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class BufferGeometrySerializationAdapter extends BinaryClassSerializationAdapter {
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
|
|
116
|
+
this.klass = BufferGeometry;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @param {BinaryBuffer} buffer
|
|
122
|
+
* @param {BufferGeometry} value
|
|
123
|
+
*/
|
|
124
|
+
serialize(buffer, value) {
|
|
125
|
+
// write index if one exists
|
|
126
|
+
const index = value.getIndex();
|
|
127
|
+
if (index === null) {
|
|
128
|
+
buffer.writeUint8(0);
|
|
129
|
+
} else {
|
|
130
|
+
buffer.writeUint8(1);
|
|
131
|
+
|
|
132
|
+
write_attribute(buffer, index);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const attributes = value.attributes;
|
|
136
|
+
const attribute_keys = Object.keys(attributes);
|
|
137
|
+
|
|
138
|
+
const attribute_count = attribute_keys.length;
|
|
139
|
+
buffer.writeUintVar(attribute_count);
|
|
140
|
+
|
|
141
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
142
|
+
const attribute_key = attribute_keys[i];
|
|
143
|
+
|
|
144
|
+
buffer.writeUTF8String(attribute_key);
|
|
145
|
+
|
|
146
|
+
const attribute = attributes[attribute_key];
|
|
147
|
+
|
|
148
|
+
write_attribute(buffer, attribute);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param {BinaryBuffer} buffer
|
|
155
|
+
* @param {BufferGeometry} value
|
|
156
|
+
*/
|
|
157
|
+
deserialize(buffer, value) {
|
|
158
|
+
const index_flag = buffer.readUint8();
|
|
159
|
+
|
|
160
|
+
if (index_flag !== 0) {
|
|
161
|
+
value.setIndex(read_attribute(buffer));
|
|
162
|
+
} else {
|
|
163
|
+
value.setIndex(null);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const attribute_count = buffer.readUintVar();
|
|
167
|
+
|
|
168
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
169
|
+
const attribute_key = buffer.readUTF8String();
|
|
170
|
+
|
|
171
|
+
const attribute = read_attribute(buffer);
|
|
172
|
+
|
|
173
|
+
value.setAttribute(attribute_key, attribute);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -132,6 +132,7 @@ function makeConfig(engine) {
|
|
|
132
132
|
|
|
133
133
|
// Plugins
|
|
134
134
|
config.addPlugin(MicronRenderPlugin);
|
|
135
|
+
config.addPlugin(AmbientOcclusionPostProcessEffect);
|
|
135
136
|
|
|
136
137
|
|
|
137
138
|
// Knowledge
|
|
@@ -159,8 +160,6 @@ async function init(harness) {
|
|
|
159
160
|
await engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
|
|
160
161
|
|
|
161
162
|
|
|
162
|
-
await engine.plugins.acquire(AmbientOcclusionPostProcessEffect);
|
|
163
|
-
|
|
164
163
|
await harness.initialize();
|
|
165
164
|
|
|
166
165
|
main(engine);
|
|
@@ -3,7 +3,7 @@ import { BlurShaderUtils, DepthLimitedBlurShader } from "three/examples/jsm/shad
|
|
|
3
3
|
import { renderScreenSpace } from "../../utils/renderScreenSpace.js";
|
|
4
4
|
|
|
5
5
|
export class DepthLimitedBlur {
|
|
6
|
-
constructor({ format = RGBAFormat }) {
|
|
6
|
+
constructor({ format = RGBAFormat, radius = 8 }) {
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -41,7 +41,7 @@ export class DepthLimitedBlur {
|
|
|
41
41
|
|
|
42
42
|
this.__depth_cutoff = 0.01;
|
|
43
43
|
|
|
44
|
-
this.__blur_radius =
|
|
44
|
+
this.__blur_radius = radius;
|
|
45
45
|
this.__blur_std_dev = 4;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -33,7 +33,7 @@ export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
|
|
|
33
33
|
// AO parameters
|
|
34
34
|
const uniforms = this.__material.uniforms;
|
|
35
35
|
uniforms.bias.value = 0.5;
|
|
36
|
-
uniforms.intensity.value =
|
|
36
|
+
uniforms.intensity.value = 2;
|
|
37
37
|
|
|
38
38
|
uniforms.kernelRadius.value = 30;
|
|
39
39
|
uniforms.minResolution.value = 0;
|
|
@@ -16,7 +16,6 @@ const SAOShader = {
|
|
|
16
16
|
uniforms: {
|
|
17
17
|
|
|
18
18
|
'tDepth': { value: null },
|
|
19
|
-
'tDiffuse': { value: null },
|
|
20
19
|
'tNormal': { value: null },
|
|
21
20
|
'size': { value: new Vector2(512, 512) },
|
|
22
21
|
|
|
@@ -47,10 +46,6 @@ const SAOShader = {
|
|
|
47
46
|
|
|
48
47
|
varying vec2 vUv;
|
|
49
48
|
|
|
50
|
-
#if DIFFUSE_TEXTURE == 1
|
|
51
|
-
uniform sampler2D tDiffuse;
|
|
52
|
-
#endif
|
|
53
|
-
|
|
54
49
|
uniform sampler2D tDepth;
|
|
55
50
|
|
|
56
51
|
#if NORMAL_TEXTURE == 1
|
|
@@ -75,14 +70,6 @@ const SAOShader = {
|
|
|
75
70
|
|
|
76
71
|
out float out_occlusion;
|
|
77
72
|
|
|
78
|
-
vec4 getDefaultColor( const in vec2 screenPosition ) {
|
|
79
|
-
#if DIFFUSE_TEXTURE == 1
|
|
80
|
-
return texture2D( tDiffuse, vUv );
|
|
81
|
-
#else
|
|
82
|
-
return vec4( 1.0 );
|
|
83
|
-
#endif
|
|
84
|
-
}
|
|
85
|
-
|
|
86
73
|
float getDepth( const in vec2 screenPosition ) {
|
|
87
74
|
#if DEPTH_PACKING == 1
|
|
88
75
|
return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );
|
|
@@ -114,7 +101,14 @@ const SAOShader = {
|
|
|
114
101
|
return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );
|
|
115
102
|
#endif
|
|
116
103
|
}
|
|
117
|
-
|
|
104
|
+
|
|
105
|
+
// Non-sin based hash function, fast and has good randomness
|
|
106
|
+
float hash12(vec2 p){
|
|
107
|
+
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
|
108
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
109
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
110
|
+
}
|
|
111
|
+
|
|
118
112
|
float minResolutionMultipliedByCameraFar;
|
|
119
113
|
|
|
120
114
|
float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {
|
|
@@ -139,7 +133,7 @@ const SAOShader = {
|
|
|
139
133
|
vec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );
|
|
140
134
|
|
|
141
135
|
// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
|
|
142
|
-
float angle =
|
|
136
|
+
float angle = hash12( vUv + randomSeed ) * PI2;
|
|
143
137
|
vec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;
|
|
144
138
|
|
|
145
139
|
float occlusionSum = 0.0;
|
|
@@ -83,6 +83,7 @@ import { ShadedGeometrySystem } from "../../../ecs/mesh-v2/ShadedGeometrySystem.
|
|
|
83
83
|
import { FogOfWar } from "../../../../ecs/fow/FogOfWar.js";
|
|
84
84
|
import { FogOfWarRevealer } from "../../../../ecs/fow/FogOfWarRevealer.js";
|
|
85
85
|
import Team from "../../../../../../model/game/ecs/component/Team.js";
|
|
86
|
+
import { AmbientOcclusionPostProcessEffect } from "../../buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js";
|
|
86
87
|
|
|
87
88
|
const geo_light_center_octahedron = new BoxBufferGeometry(0.1, 0.1, 0.1);
|
|
88
89
|
const engineHarness = new EngineHarness();
|
|
@@ -163,6 +164,7 @@ function makeConfig(engine) {
|
|
|
163
164
|
|
|
164
165
|
// Plugins
|
|
165
166
|
config.addPlugin(ForwardPlusRenderingPlugin);
|
|
167
|
+
config.addPlugin(AmbientOcclusionPostProcessEffect);
|
|
166
168
|
// config.addPlugin(MicronRenderPlugin);
|
|
167
169
|
|
|
168
170
|
// Knowledge
|
|
@@ -116,14 +116,16 @@ export function query_bvh_frustum_from_texture(
|
|
|
116
116
|
const radius = source_data[light_address + 3];
|
|
117
117
|
|
|
118
118
|
if (!point_light_inside_volume(light_x, light_y, light_z, radius, points, planes)) {
|
|
119
|
+
// cull
|
|
119
120
|
continue;
|
|
120
121
|
}
|
|
122
|
+
|
|
121
123
|
} else if (light_type === 3) {
|
|
122
124
|
// decal
|
|
123
125
|
debugger;
|
|
124
126
|
|
|
125
127
|
} else {
|
|
126
|
-
throw new Error(
|
|
128
|
+
throw new Error(`Unsupported light type ${light_type}`);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
// write to output
|
|
@@ -95,12 +95,18 @@ export class ShadowMapRenderer {
|
|
|
95
95
|
|
|
96
96
|
this.onBeforeRender.send3(renderer, shadow_camera, scene);
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
if (target.width <= 0 || target.height <= 0) {
|
|
99
|
+
// no point in rendering
|
|
100
|
+
} else {
|
|
101
|
+
// do the draw
|
|
102
|
+
renderer.render(scene, shadow_camera);
|
|
103
|
+
|
|
104
|
+
if (renderer.shadowMap.type === VSMShadowMap) {
|
|
105
|
+
this.__do_vsm_pass(shadow);
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
|
|
104
110
|
// restore state
|
|
105
111
|
renderer.setRenderTarget(__rt, __acf, __aml);
|
|
106
112
|
renderer.setScissorTest(__scissor);
|
|
@@ -570,6 +570,10 @@ Sampler2D.prototype.sampleChannelBicubic = function (x, y, channel) {
|
|
|
570
570
|
const x1 = clamp(x, 0, x_max) | 0;
|
|
571
571
|
const y1 = clamp(y, 0, y_max) | 0;
|
|
572
572
|
|
|
573
|
+
// fractional texel position (from the nearest low texel)
|
|
574
|
+
const xd = x - x1;
|
|
575
|
+
const yd = y - y1;
|
|
576
|
+
|
|
573
577
|
const x0 = max2(0, x1 - 1);
|
|
574
578
|
const y0 = max2(0, y1 - 1);
|
|
575
579
|
|
|
@@ -595,61 +599,36 @@ Sampler2D.prototype.sampleChannelBicubic = function (x, y, channel) {
|
|
|
595
599
|
const col2_offset = x2 * itemSize;
|
|
596
600
|
const col3_offset = x3 * itemSize;
|
|
597
601
|
|
|
598
|
-
//
|
|
599
|
-
const
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
const j0 = row1_address + col0_offset;
|
|
605
|
-
const j1 = row1_address + col1_offset;
|
|
606
|
-
const j2 = row1_address + col2_offset;
|
|
607
|
-
const j3 = row1_address + col3_offset;
|
|
602
|
+
// read samples
|
|
603
|
+
const vi0 = data[row0_address + col0_offset];
|
|
604
|
+
const vi1 = data[row0_address + col1_offset];
|
|
605
|
+
const vi2 = data[row0_address + col2_offset];
|
|
606
|
+
const vi3 = data[row0_address + col3_offset];
|
|
608
607
|
|
|
609
|
-
const
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
608
|
+
const vj0 = data[row1_address + col0_offset];
|
|
609
|
+
const vj1 = data[row1_address + col1_offset];
|
|
610
|
+
const vj2 = data[row1_address + col2_offset];
|
|
611
|
+
const vj3 = data[row1_address + col3_offset];
|
|
613
612
|
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
613
|
+
const vk0 = data[row2_address + col0_offset];
|
|
614
|
+
const vk1 = data[row2_address + col1_offset];
|
|
615
|
+
const vk2 = data[row2_address + col2_offset];
|
|
616
|
+
const vk3 = data[row2_address + col3_offset];
|
|
618
617
|
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
const
|
|
622
|
-
const
|
|
623
|
-
const vi3 = data[i3];
|
|
624
|
-
|
|
625
|
-
const vj0 = data[j0];
|
|
626
|
-
const vj1 = data[j1];
|
|
627
|
-
const vj2 = data[j2];
|
|
628
|
-
const vj3 = data[j3];
|
|
629
|
-
|
|
630
|
-
const vk0 = data[k0];
|
|
631
|
-
const vk1 = data[k1];
|
|
632
|
-
const vk2 = data[k2];
|
|
633
|
-
const vk3 = data[k3];
|
|
634
|
-
|
|
635
|
-
const vl0 = data[l0];
|
|
636
|
-
const vl1 = data[l1];
|
|
637
|
-
const vl2 = data[l2];
|
|
638
|
-
const vl3 = data[l3];
|
|
618
|
+
const vl0 = data[row3_address + col0_offset];
|
|
619
|
+
const vl1 = data[row3_address + col1_offset];
|
|
620
|
+
const vl2 = data[row3_address + col2_offset];
|
|
621
|
+
const vl3 = data[row3_address + col3_offset];
|
|
639
622
|
|
|
640
|
-
const xd = x - x1;
|
|
641
|
-
const yd = y - y1;
|
|
642
623
|
|
|
643
|
-
// perform filtering in X
|
|
624
|
+
// perform filtering in X (rows)
|
|
644
625
|
const s0 = bicubic_terp(xd, vi0, vi1, vi2, vi3);
|
|
645
626
|
const s1 = bicubic_terp(xd, vj0, vj1, vj2, vj3);
|
|
646
627
|
const s2 = bicubic_terp(xd, vk0, vk1, vk2, vk3);
|
|
647
628
|
const s3 = bicubic_terp(xd, vl0, vl1, vl2, vl3);
|
|
648
629
|
|
|
649
|
-
// filter in Y
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
return result;
|
|
630
|
+
// filter in Y (columns)
|
|
631
|
+
return bicubic_terp(yd, s0, s1, s2, s3);
|
|
653
632
|
};
|
|
654
633
|
|
|
655
634
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EntityBehavior } from "./EntityBehavior.js";
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
3
|
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
4
|
+
import { assert } from "../../../../core/assert.js";
|
|
4
5
|
|
|
5
6
|
export class WaitForEventBehavior extends EntityBehavior {
|
|
6
7
|
constructor() {
|
|
@@ -26,6 +27,8 @@ export class WaitForEventBehavior extends EntityBehavior {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
fromJSON({ event, target = -1 }) {
|
|
30
|
+
assert.isString(event, 'event');
|
|
31
|
+
|
|
29
32
|
this.event = event;
|
|
30
33
|
this.target = target;
|
|
31
34
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import Storage from "../Storage.js";
|
|
2
2
|
import { IndexedDBTransactionMode } from "./IndexedDBTransactionMode.js";
|
|
3
|
+
import { assert } from "../../../core/assert.js";
|
|
3
4
|
|
|
4
5
|
const MAIN_STORE_NAME = 'main';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* TODO add QuotaExceededError handling
|
|
9
|
+
*/
|
|
6
10
|
export class IndexedDBStorage extends Storage {
|
|
7
11
|
constructor(name) {
|
|
8
12
|
super();
|
|
9
13
|
|
|
14
|
+
assert.isString(name, 'name');
|
|
15
|
+
|
|
10
16
|
/**
|
|
11
17
|
*
|
|
12
18
|
* @param {IDBDatabase} database
|
|
@@ -43,7 +49,7 @@ export class IndexedDBStorage extends Storage {
|
|
|
43
49
|
|
|
44
50
|
const objectStore = transaction.objectStore(MAIN_STORE_NAME);
|
|
45
51
|
|
|
46
|
-
const idbRequest = objectStore.delete(
|
|
52
|
+
const idbRequest = objectStore.delete(key);
|
|
47
53
|
|
|
48
54
|
if (typeof resolve === "function") {
|
|
49
55
|
|
|
@@ -60,6 +66,7 @@ export class IndexedDBStorage extends Storage {
|
|
|
60
66
|
});
|
|
61
67
|
|
|
62
68
|
}
|
|
69
|
+
|
|
63
70
|
});
|
|
64
71
|
|
|
65
72
|
if (typeof reject === "function") {
|
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.33.
|
|
8
|
+
"version": "2.33.60",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|