@woosh/meep-engine 2.34.36 → 2.34.40
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/BinaryNode.js +872 -965
- package/core/bvh2/LeafNode.js +82 -75
- package/core/bvh2/Node.js +112 -114
- package/core/bvh2/aabb3/AABB3.spec.js +27 -1
- package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +1 -1
- package/core/geom/3d/aabb/aabb3_matrix4_project.js +1 -1
- package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +13 -0
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -2
- package/core/geom/Vector3.js +22 -11
- package/engine/ecs/foliage/InstancedFoliage.js +8 -4
- package/engine/ecs/foliage/ViewState.js +5 -30
- package/engine/ecs/foliage/ecs/Foliage2System.js +2 -7
- package/engine/graphics/GraphicsEngine.js +1 -1
- package/engine/graphics/ecs/camera/Camera.js +33 -16
- package/engine/graphics/ecs/camera/unprojectPoint.js +14 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +24 -2
- package/engine/graphics/ecs/water2/shader/AlexWaterShader.js +7 -1
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +0 -7
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +5 -1
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +3 -1
- package/engine/graphics/render/buffer/simple-fx/ao/SAOShader.js +2 -1
- package/engine/plugin/EnginePluginManager.js +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BitSet } from "../../../core/binary/BitSet.js";
|
|
2
2
|
import { InstancedMeshGroup } from "../../graphics/geometry/instancing/InstancedMeshGroup.js";
|
|
3
|
-
import { assert } from "../../../core/assert.js";
|
|
4
3
|
import { queryBinaryNode_FrustumIntersections_Data } from "../../../core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js";
|
|
5
4
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
6
5
|
|
|
@@ -48,30 +47,6 @@ export class ViewState {
|
|
|
48
47
|
this.instances.dispose();
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {number} index
|
|
55
|
-
* @param {int} ref
|
|
56
|
-
*/
|
|
57
|
-
__updateVisibility(index, ref) {
|
|
58
|
-
assert.isNonNegativeInteger(ref, 'ref');
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @type {BitSet}
|
|
63
|
-
*/
|
|
64
|
-
const visibleElementSet = this.__visible_set;
|
|
65
|
-
|
|
66
|
-
if (!visibleElementSet.get(ref)) {
|
|
67
|
-
//no longer visible
|
|
68
|
-
this.__garbage[this.__garbagePointer++] = ref;
|
|
69
|
-
} else {
|
|
70
|
-
//visible, and is already in the group, update the set
|
|
71
|
-
visibleElementSet.set(ref, false);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
50
|
__compute_visibility_update() {
|
|
76
51
|
const instances = this.instances;
|
|
77
52
|
|
|
@@ -127,16 +102,16 @@ export class ViewState {
|
|
|
127
102
|
*/
|
|
128
103
|
update(bvh, data) {
|
|
129
104
|
|
|
105
|
+
const visible_instance_set = this.__visible_set;
|
|
106
|
+
|
|
107
|
+
const instances = this.instances;
|
|
108
|
+
|
|
130
109
|
// reset visible set
|
|
131
|
-
|
|
110
|
+
visible_instance_set.reset();
|
|
132
111
|
|
|
133
112
|
//reset garbage pointer
|
|
134
113
|
this.__garbagePointer = 0;
|
|
135
114
|
|
|
136
|
-
const instances = this.instances;
|
|
137
|
-
|
|
138
|
-
const visible_instance_set = this.__visible_set;
|
|
139
|
-
|
|
140
115
|
|
|
141
116
|
// collect visible instances
|
|
142
117
|
const collected_nodes = queryBinaryNode_FrustumIntersections_Data(scratch_array, 0, bvh, this.__view.frustum);
|
|
@@ -26,13 +26,8 @@ function cleanupLayer(layerData, renderLayer) {
|
|
|
26
26
|
export function loadFoliageLayer(layer, assetManager) {
|
|
27
27
|
const instancedFoliage = layer.data;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
const threeMesh = instancedFoliage.instances.mesh;
|
|
33
|
-
|
|
34
|
-
threeMesh.castShadow = layer.castShadow.getValue();
|
|
35
|
-
threeMesh.receiveShadow = layer.receiveShadow.getValue();
|
|
29
|
+
instancedFoliage.castShadow = layer.castShadow.getValue();
|
|
30
|
+
instancedFoliage.receiveShadow = layer.receiveShadow.getValue();
|
|
36
31
|
|
|
37
32
|
const modelURL = layer.modelURL.getValue();
|
|
38
33
|
|
|
@@ -538,7 +538,7 @@ function classifyPassTypeFromObject(object) {
|
|
|
538
538
|
* @type {THREE.Material}
|
|
539
539
|
*/
|
|
540
540
|
const material = object.material;
|
|
541
|
-
if (material.
|
|
541
|
+
if (material.depthWrite === false && material.depthTest === false) {
|
|
542
542
|
return RenderPassType.Transparent;
|
|
543
543
|
}
|
|
544
544
|
}
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
|
|
7
7
|
import ObservedEnum from "../../../../core/model/ObservedEnum.js";
|
|
8
|
-
import {Frustum
|
|
9
|
-
import {assert} from "../../../../core/assert.js";
|
|
8
|
+
import { Frustum } from 'three';
|
|
9
|
+
import { assert } from "../../../../core/assert.js";
|
|
10
10
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
11
|
-
import {frustumFromCamera} from "./CameraSystem.js";
|
|
12
|
-
import {computePointDistanceToPlane} from "../../../../core/geom/Plane.js";
|
|
11
|
+
import { frustumFromCamera } from "./CameraSystem.js";
|
|
12
|
+
import { computePointDistanceToPlane } from "../../../../core/geom/Plane.js";
|
|
13
|
+
import { unprojectPoint } from "./unprojectPoint.js";
|
|
14
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
@@ -116,15 +118,15 @@ export class Camera {
|
|
|
116
118
|
|
|
117
119
|
/**
|
|
118
120
|
*
|
|
119
|
-
* @param {Camera} camera
|
|
121
|
+
* @param {Camera|THREE.PerspectiveCamera|THREE.OrthographicCamera} camera
|
|
120
122
|
* @param {number} x
|
|
121
123
|
* @param {number} y
|
|
122
124
|
* @param {Vector3} source
|
|
123
125
|
* @param {Vector3} direction
|
|
124
126
|
*/
|
|
125
127
|
static projectRay(camera, x, y, source, direction) {
|
|
126
|
-
assert.
|
|
127
|
-
assert.
|
|
128
|
+
assert.defined(camera, "camera");
|
|
129
|
+
assert.defined(camera.position, "Camera.position");
|
|
128
130
|
|
|
129
131
|
|
|
130
132
|
assert.isNumber(x, 'x');
|
|
@@ -136,18 +138,32 @@ export class Camera {
|
|
|
136
138
|
// assert.ok(y >= -1, `Y(=${y}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
137
139
|
// assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
138
140
|
|
|
139
|
-
|
|
141
|
+
if (camera.isPerspectiveCamera) {
|
|
142
|
+
scratch_v3_1.setFromMatrixPosition(camera.matrixWorld.elements);
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
scratch_v3_0.set(x, y, 0.5);
|
|
142
145
|
|
|
143
|
-
|
|
146
|
+
// NOTE: projection inverse and world matrices are used in "unproject" operation, we update those to make things work as intended. This is handled by the camera system
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
unprojectPoint(
|
|
149
|
+
scratch_v3_0,
|
|
150
|
+
scratch_v3_0,
|
|
151
|
+
camera.projectionMatrixInverse.elements,
|
|
152
|
+
camera.matrixWorld.elements
|
|
153
|
+
);
|
|
146
154
|
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
//get direction
|
|
156
|
+
scratch_v3_0.sub(scratch_v3_1);
|
|
157
|
+
scratch_v3_0.normalize();
|
|
149
158
|
|
|
150
|
-
|
|
159
|
+
source.copy(scratch_v3_1);
|
|
160
|
+
direction.copy(scratch_v3_0);
|
|
161
|
+
|
|
162
|
+
} else if (camera.isOrthographicCamera) {
|
|
163
|
+
throw new Error('Unsupported camera type: "Orthographic" ');
|
|
164
|
+
} else {
|
|
165
|
+
throw new Error('Unsupported camera type');
|
|
166
|
+
}
|
|
151
167
|
}
|
|
152
168
|
|
|
153
169
|
/**
|
|
@@ -179,7 +195,7 @@ export class Camera {
|
|
|
179
195
|
|
|
180
196
|
const near = scratch_frustum.planes[0];
|
|
181
197
|
|
|
182
|
-
|
|
198
|
+
scratch_v3_0.set(x, y, z);
|
|
183
199
|
|
|
184
200
|
const normal = near.normal;
|
|
185
201
|
|
|
@@ -199,7 +215,8 @@ Camera.typeName = "Camera";
|
|
|
199
215
|
|
|
200
216
|
Camera.ProjectionType = ProjectionType;
|
|
201
217
|
|
|
202
|
-
const
|
|
218
|
+
const scratch_v3_0 = new Vector3();
|
|
219
|
+
const scratch_v3_1 = new Vector3();
|
|
203
220
|
const scratch_frustum = new Frustum();
|
|
204
221
|
|
|
205
222
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Vector3} result
|
|
6
|
+
* @param {Vector3} input
|
|
7
|
+
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
8
|
+
* @param {number[]} world_matrix world transform
|
|
9
|
+
*/
|
|
10
|
+
export function unprojectPoint(result, input, projection_matrix_inverse, world_matrix) {
|
|
11
|
+
result.copy(input);
|
|
12
|
+
result.applyMatrix4(projection_matrix_inverse);
|
|
13
|
+
result.applyMatrix4(world_matrix);
|
|
14
|
+
}
|
|
@@ -44,8 +44,30 @@ function __getDepthMaterial(object) {
|
|
|
44
44
|
* @return {boolean}
|
|
45
45
|
*/
|
|
46
46
|
function scene_object_filter(object3D) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
if (object3D.castShadow === false) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (object3D.visible === false) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (object3D.isMesh) {
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @type {THREE.Material|null|undefined}
|
|
60
|
+
*/
|
|
61
|
+
const material = (object3D.customDepthMaterial !== null ? object3D.customDepthMaterial : object3D.material);
|
|
62
|
+
|
|
63
|
+
if (material && material.visible === false) {
|
|
64
|
+
//material's main
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
49
71
|
}
|
|
50
72
|
|
|
51
73
|
export class ThreeLightBinding extends LightBinding {
|
|
@@ -228,7 +228,13 @@ export function makeAlexWaterMaterial() {
|
|
|
228
228
|
blending: NormalBlending,
|
|
229
229
|
lights: false,
|
|
230
230
|
fog: false,
|
|
231
|
-
|
|
231
|
+
|
|
232
|
+
/*
|
|
233
|
+
forcing transparent pass in Graphics Engine
|
|
234
|
+
three.js and indeed WebGL doesn't provide a way to pass depth buffer into the main draw pass (to canvas), so this is a workaround
|
|
235
|
+
*/
|
|
236
|
+
depthTest: false,
|
|
237
|
+
depthWrite: false,
|
|
232
238
|
transparent: true,
|
|
233
239
|
vertexColors: false
|
|
234
240
|
});
|
|
@@ -68,13 +68,6 @@ export class MicronGeometryPatch {
|
|
|
68
68
|
*/
|
|
69
69
|
this.children = [];
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Runtime dependency patches, if this patch is refined at runtime - dependencies must be refined as well
|
|
73
|
-
* These dependencies allow for more aggressive simplification of topology
|
|
74
|
-
* @type {number[]}
|
|
75
|
-
*/
|
|
76
|
-
this.dependencies = [];
|
|
77
|
-
|
|
78
71
|
/**
|
|
79
72
|
* Level of detail, lower number means more detailed
|
|
80
73
|
* @type {number}
|
package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js
CHANGED
|
@@ -464,7 +464,11 @@ export function make_particle_billboard_shader({ lights = false } = {}) {
|
|
|
464
464
|
fragmentShader: make_fragment_shader(),
|
|
465
465
|
blending: CustomBlending,
|
|
466
466
|
lights: lights,
|
|
467
|
-
|
|
467
|
+
/*
|
|
468
|
+
forcing transparent pass in Graphics Engine
|
|
469
|
+
three.js and indeed WebGL doesn't provide a way to pass depth buffer into the main draw pass (to canvas), so this is a workaround
|
|
470
|
+
*/
|
|
471
|
+
depthTest: false,
|
|
468
472
|
depthWrite: false,
|
|
469
473
|
transparent: true,
|
|
470
474
|
vertexColors: false,
|
|
@@ -27,7 +27,9 @@ export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
|
|
|
27
27
|
fragmentShader: SAOShader.fragmentShader,
|
|
28
28
|
vertexShader: SAOShader.vertexShader,
|
|
29
29
|
uniforms: UniformsUtils.clone(SAOShader.uniforms),
|
|
30
|
-
glslVersion: GLSL3
|
|
30
|
+
glslVersion: GLSL3,
|
|
31
|
+
depthWrite: false,
|
|
32
|
+
depthTest: false
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
// AO parameters
|
|
@@ -82,6 +82,7 @@ export class EnginePluginManager extends BaseProcess {
|
|
|
82
82
|
if (state === ProcessState.Initialized || state === ProcessState.Running) {
|
|
83
83
|
const dependencies = plugin.dependencies;
|
|
84
84
|
|
|
85
|
+
// resolve dependencies
|
|
85
86
|
for (let i = 0; i < dependencies.length; i++) {
|
|
86
87
|
const dependency = dependencies[i];
|
|
87
88
|
|
|
@@ -206,7 +207,7 @@ export class EnginePluginManager extends BaseProcess {
|
|
|
206
207
|
async shutdown() {
|
|
207
208
|
super.shutdown();
|
|
208
209
|
|
|
209
|
-
return this.__transition_active_plugins_to(ProcessState.
|
|
210
|
+
return this.__transition_active_plugins_to(ProcessState.Finalized);
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
/**
|
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.40",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|