@woosh/meep-engine 2.169.3 → 2.169.4
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/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"author": "Alexander Goldring",
|
|
9
|
-
"version": "2.169.
|
|
9
|
+
"version": "2.169.4",
|
|
10
10
|
"main": "build/meep.module.js",
|
|
11
11
|
"module": "build/meep.module.js",
|
|
12
12
|
"exports": {
|
|
@@ -192,7 +192,14 @@ export class InstancedMeshGroup {
|
|
|
192
192
|
}
|
|
193
193
|
export type CacheKey = {
|
|
194
194
|
color: Material;
|
|
195
|
+
/**
|
|
196
|
+
* material for the depth shadow pass, used by directional and spot lights
|
|
197
|
+
*/
|
|
195
198
|
depth: Material;
|
|
199
|
+
/**
|
|
200
|
+
* material for the distance shadow pass, used by point lights
|
|
201
|
+
*/
|
|
202
|
+
distance: Material;
|
|
196
203
|
};
|
|
197
204
|
import { BufferGeometry } from 'three';
|
|
198
205
|
import { Mesh } from 'three';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"AA2CA;IA2jBI;;;;;OAKG;IACH,sBAJW,oBAAoB,uBAElB,kBAAkB,CAS9B;IAlkBG;;;;OAIG;IACH,wBAA2B;IAE3B;;;;OAIG;IACH,gCAAmC;IAEnC;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAEK;IACrB;;;OAGG;IACH,c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|
LineSegments,
|
|
8
8
|
Mesh,
|
|
9
9
|
MeshDepthMaterial,
|
|
10
|
+
MeshDistanceMaterial,
|
|
10
11
|
RGBADepthPacking
|
|
11
12
|
} from 'three';
|
|
12
13
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
@@ -26,7 +27,8 @@ import { rewriteMaterial } from "./rewriteMaterial.js";
|
|
|
26
27
|
/**
|
|
27
28
|
* @typedef {Object} CacheKey
|
|
28
29
|
* @property {Material} color
|
|
29
|
-
* @property {Material} depth
|
|
30
|
+
* @property {Material} depth material for the depth shadow pass, used by directional and spot lights
|
|
31
|
+
* @property {Material} distance material for the distance shadow pass, used by point lights
|
|
30
32
|
*/
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -180,6 +182,7 @@ export class InstancedMeshGroup {
|
|
|
180
182
|
new_object.receiveShadow = this.mesh.receiveShadow;
|
|
181
183
|
|
|
182
184
|
new_object.customDepthMaterial = this.mesh.customDepthMaterial;
|
|
185
|
+
new_object.customDistanceMaterial = this.mesh.customDistanceMaterial;
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
this.mesh = new_object;
|
|
@@ -269,24 +272,44 @@ export class InstancedMeshGroup {
|
|
|
269
272
|
|
|
270
273
|
material.onBeforeCompile = composeCompile(sourceMaterial.onBeforeCompile, rewriteMaterial);
|
|
271
274
|
|
|
272
|
-
//
|
|
275
|
+
// We need custom shadow materials to ensure shadows will be drawn correctly.
|
|
276
|
+
//
|
|
277
|
+
// Instancing here is not three's own: the per-instance transform lives in an
|
|
278
|
+
// `instanceMatrix` attribute on our InstancedBufferGeometry and is applied by the
|
|
279
|
+
// `rewriteMaterial` shader patch, NOT by three's `USE_INSTANCING` (which keys off
|
|
280
|
+
// `Object3D.isInstancedMesh`, and this mesh is a plain Mesh). So every material
|
|
281
|
+
// this geometry is ever drawn with has to carry the patch, or that draw renders
|
|
282
|
+
// every instance at the local origin.
|
|
283
|
+
//
|
|
284
|
+
// There are two shadow passes and they take different materials: depth for
|
|
285
|
+
// directional and spot lights, distance for point lights (which compare world-space
|
|
286
|
+
// distance to the light rather than projected depth). Both are honoured by
|
|
287
|
+
// ThreeLightBinding, which prefers `customDepthMaterial`/`customDistanceMaterial`
|
|
288
|
+
// over its own unpatched fallbacks.
|
|
273
289
|
const depthMaterial = new MeshDepthMaterial({
|
|
274
290
|
depthPacking: RGBADepthPacking,
|
|
275
291
|
});
|
|
276
292
|
|
|
277
|
-
|
|
293
|
+
const distanceMaterial = new MeshDistanceMaterial();
|
|
294
|
+
|
|
295
|
+
//if the source material uses alpha testing - enable it on the shadow materials
|
|
278
296
|
if (material.alphaTest !== 0) {
|
|
279
297
|
depthMaterial.alphaTest = material.alphaTest;
|
|
280
298
|
depthMaterial.map = material.map;
|
|
299
|
+
|
|
300
|
+
distanceMaterial.alphaTest = material.alphaTest;
|
|
301
|
+
distanceMaterial.map = material.map;
|
|
281
302
|
}
|
|
282
303
|
|
|
283
304
|
depthMaterial.onBeforeCompile = rewriteMaterial;
|
|
305
|
+
distanceMaterial.onBeforeCompile = rewriteMaterial;
|
|
284
306
|
|
|
285
307
|
const cachedMaterial = StaticMaterialCache.Global.acquire(material);
|
|
286
308
|
|
|
287
309
|
return {
|
|
288
310
|
color: cachedMaterial,
|
|
289
|
-
depth: StaticMaterialCache.Global.acquire(depthMaterial)
|
|
311
|
+
depth: StaticMaterialCache.Global.acquire(depthMaterial),
|
|
312
|
+
distance: StaticMaterialCache.Global.acquire(distanceMaterial)
|
|
290
313
|
};
|
|
291
314
|
|
|
292
315
|
}
|
|
@@ -302,6 +325,7 @@ export class InstancedMeshGroup {
|
|
|
302
325
|
|
|
303
326
|
this.mesh.material = m.color;
|
|
304
327
|
this.mesh.customDepthMaterial = m.depth;
|
|
328
|
+
this.mesh.customDistanceMaterial = m.distance;
|
|
305
329
|
}
|
|
306
330
|
|
|
307
331
|
/**
|