@woosh/meep-engine 2.34.36 → 2.34.37
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 +852 -956
- package/core/bvh2/LeafNode.js +80 -82
- package/core/bvh2/Node.js +111 -114
- package/core/bvh2/aabb3/AABB3.spec.js +27 -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 +6 -2
- 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/water2/shader/AlexWaterShader.js +7 -1
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +5 -1
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -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
|
});
|
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,
|
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.37",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|