@woosh/meep-engine 2.63.0 → 2.64.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.
Files changed (34) hide show
  1. package/build/meep.cjs +30 -23
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +30 -23
  4. package/package.json +1 -1
  5. package/src/core/binary/UINT16_MAX.js +5 -0
  6. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +5 -5
  7. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
  8. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
  9. package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
  10. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +12 -4
  11. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
  12. package/src/core/collection/list/List.js +9 -3
  13. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
  14. package/src/core/geom/Vector2.js +6 -4
  15. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +49 -86
  16. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
  17. package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
  18. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +17 -17
  19. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
  20. package/src/engine/ecs/foliage/Foliage.js +0 -151
  21. package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
  22. package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
  23. package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
  24. package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
  25. package/src/engine/ecs/foliage/ViewState.js +0 -181
  26. package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
  27. package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
  28. package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
  29. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
  30. package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
  31. package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
  32. package/src/engine/save/storage/GooglePlayStorage.js +0 -47
  33. package/src/engine/save/storage/JsonStringCodec.js +0 -24
  34. /package/src/engine/sound/ecs/emitter/{SoundEmitter.spec.js → SoundEmitterSerializationAdapter.spec.js} +0 -0
@@ -1,151 +0,0 @@
1
- /**
2
- * Created by Alex on 18/10/2014.
3
- */
4
- import SampleTraverser from '../../graphics/texture/sampler/SampleTraverser.js';
5
- import QuadGeometry from '../../graphics/geometry/QuadGeometry.js';
6
- import * as THREE from 'three';
7
-
8
- import ThreeFactory from '../../graphics/three/ThreeFactory.js';
9
-
10
-
11
- function makeCombinedGeometry(templateGeometry, normalAlign, width, height, count, scale, heightMap, material) {
12
- const geometry = new THREE.Geometry();
13
-
14
- const scaleMatrix = new THREE.Matrix4();
15
- scaleMatrix.makeScale(scale.x, scale.y, scale.z);
16
-
17
- function process(x, z) {
18
- const y = heightMap.sampleHeight(x, z);
19
- const pos = new THREE.Vector3(x, y, z);
20
- //
21
- const g = templateGeometry.clone();
22
- //transform
23
- const m = new THREE.Matrix4();
24
- if (normalAlign) {
25
- const normal = heightMap.sampleNormal(x, z);
26
- m.lookAt(normal, new THREE.Vector3(), new THREE.Vector3(0, 1, 0));
27
- }
28
- m.setPosition(pos);
29
- m.multiply(scaleMatrix);
30
- g.applyMatrix4(m);
31
- geometry.merge(g);
32
- }
33
-
34
- createPieces(process, count, width, height);
35
- const mesh = new THREE.Mesh(geometry, material);
36
- return mesh;
37
- }
38
-
39
- function makeMultiMesh(templateGeometry, normalAlign, width, height, count, scale, heightMap, material) {
40
- const object = new THREE.Object3D();
41
-
42
-
43
- function process(x, z) {
44
- const y = heightMap.sampleHeight(x, z);
45
- //
46
- const m = new THREE.Mesh(templateGeometry, material);
47
- //transform
48
- if (normalAlign) {
49
- const normal = heightMap.sampleNormal(x, z);
50
- m.lookAt(normal, new THREE.Vector3(), new THREE.Vector3(0, 1, 0));
51
- }
52
- m.position.set(x, y, z);
53
- m.scale.set(scale.x, scale.y, scale.z);
54
- object.add(m);
55
- }
56
-
57
- createPieces(process, count, width, height);
58
-
59
- return object;
60
- }
61
-
62
- function createPieces(process, count, width, height) {
63
- for (let i = 0; i < count; i++) {
64
- const x = width * Math.random();
65
- const z = height * Math.random();
66
- process(x, z);
67
- }
68
- }
69
-
70
-
71
- const alignToVector = (function () {
72
- const matrix4 = new THREE.Matrix4();
73
-
74
- function alignToVector(mesh, direction) {
75
- matrix4.identity();
76
-
77
- const el = matrix4.elements;
78
- el[4] = direction.x;
79
- el[5] = direction.y;
80
- el[6] = direction.z;
81
- mesh.rotation.setFromRotationMatrix(matrix4, 'XZY');
82
- }
83
-
84
- return alignToVector;
85
- })();
86
-
87
- const Foliage = function (options, mask, quadTree, caster) {
88
-
89
- const size = options.size || 1;
90
- const randomRotateY = options.randomRotateY !== void 0 ? options.randomRotateY : false;
91
-
92
- const templateGeometry = options.geometry || new QuadGeometry(1, 1);
93
- let boundingSphere = templateGeometry.boundingSphere;
94
- if (boundingSphere === void 0 || boundingSphere === null) {
95
- boundingSphere = templateGeometry.computeBoundingSphere();
96
- }
97
- const scaleFactor = 1 / (boundingSphere.radius * 2);
98
- const material = options.material;
99
- const density = options.density;
100
- const densityMap = options.densityMap;
101
- const normalAlign = options.normalAlign !== void 0 ? options.normalAlign : true;
102
- const castShadow = options.castShadow !== void 0 ? options.castShadow : false;
103
- const receiveShadow = options.receiveShadow !== void 0 ? options.receiveShadow : false;
104
- //
105
-
106
- const mapSize = new THREE.Vector2(options.width, options.height);
107
- //
108
- const object = new THREE.Object3D();
109
-
110
- const mapWidth = mapSize.x;
111
- const mapHeight = mapSize.y;
112
-
113
- function process(u, v, size) {
114
- const x = u * mapWidth;
115
- const z = v * mapHeight;
116
- caster(x, z, function (hit, normal, geometry) {
117
- const y = hit.y;
118
- //
119
- const m = ThreeFactory.createMesh(templateGeometry, material);
120
- //transform
121
- if (normalAlign) {
122
- // m.lookAt(normal, new THREE.Vector3(), new THREE.Vector3(0, 1, 0));
123
- alignToVector(m, normal);
124
- }
125
- if (randomRotateY) {
126
- m.rotation.y = Math.PI * 2 * Math.random();
127
- }
128
- m.position.set(x, y, z);
129
- m.castShadow = castShadow;
130
- m.receiveShadow = receiveShadow;
131
- const scale = scaleFactor * size;
132
- m.scale.set(scale, scale, scale);
133
- object.add(m);
134
- });
135
- }
136
-
137
- //
138
- //console.time('generating foliage');
139
- const sampleTraverser = new SampleTraverser();
140
- sampleTraverser.resolveSpace = true;
141
- sampleTraverser.resolveSpaceSizeMin = size.min;
142
- sampleTraverser.resolveSpaceSizeMax = size.max;
143
- sampleTraverser.mask = mask;
144
- sampleTraverser.quadTree = quadTree;
145
-
146
- sampleTraverser.traverse(densityMap, density, mapSize, process);
147
- //console.timeEnd('generating foliage');
148
- //
149
- return object;
150
- };
151
- export default Foliage;
@@ -1,39 +0,0 @@
1
- /**
2
- * Created by Alex on 21/10/2014.
3
- */
4
- import * as THREE from 'three';
5
-
6
-
7
- const Loader = function () {
8
- function load(options, callback) {
9
- const url = options.url;
10
- const density = options.density;
11
- const normalAlign = options.normalAlign;
12
- const size = options.size;
13
- const densityMap = options.densityMap;
14
- const randomRotateY = options.randomRotateY;
15
- const loader = new THREE.JSONLoader();
16
- loader.load(url, function (geometry, materials) {
17
- const material = new THREE.MultiMaterial(materials);
18
-
19
- callback({
20
- density: density,
21
- material: material,
22
- geometry: geometry,
23
- normalAlign: normalAlign,
24
- densityMap: densityMap,
25
- size: size,
26
- width: options.width,
27
- height: options.height,
28
- randomRotateY: randomRotateY,
29
- castShadow: options.castShadow,
30
- receiveShadow: options.receiveShadow
31
- });
32
- });
33
- }
34
-
35
- this.load = load;
36
- };
37
-
38
-
39
- export default Loader;
@@ -1,27 +0,0 @@
1
- import { BVHVisitor } from "../../../core/bvh2/traversal/BVHVisitor.js";
2
- import { BitSet } from "../../../core/binary/BitSet.js";
3
-
4
- export class FoliageVisibilitySetBuilder extends BVHVisitor {
5
- constructor() {
6
- super();
7
-
8
- /**
9
- *
10
- * @type {BitSet}
11
- */
12
- this.visibleSet = new BitSet();
13
- //prevent re-allocation
14
- this.visibleSet.preventShrink();
15
- }
16
-
17
- initialize() {
18
- this.visibleSet.reset();
19
- }
20
-
21
- visitLeaf(node) {
22
- const index = node.object;
23
-
24
- //TODO check screen space size to decide if element should be seen or not
25
- this.visibleSet.set(index, true);
26
- }
27
- }
@@ -1,106 +0,0 @@
1
- /**
2
- * Created by Alex on 24/10/2014.
3
- */
4
- /**
5
- * Created by Alex on 18/10/2014.
6
- */
7
- import SampleTraverser from '../../graphics/texture/sampler/SampleTraverser.js';
8
- import {
9
- Box3 as ThreeBox3,
10
- BufferAttribute,
11
- BufferGeometry,
12
- NormalBlending,
13
- PointCloud,
14
- PointCloudMaterial,
15
- Sphere as ThreeSphere,
16
- Vector3 as ThreeVector3,
17
- VertexColors
18
- } from 'three';
19
- import Vector2 from "../../../core/geom/Vector2.js";
20
- import Vector4 from "../../../core/geom/Vector4.js";
21
-
22
- /**
23
- * @deprecated use other options, such as ShadedMesh with INSTANCED draw mode or dedicated instanced mesh system such as Foliage2System
24
- * @constructor
25
- */
26
- const Foliage = function (options) {
27
- const size = options.size || 1;
28
- const lightMap = options.lightMap;
29
- const texture = options.texture;
30
- const density = options.density;
31
- const densityMap = options.densityMap;
32
- const heightMap = options.heightMap;
33
- let zRange = options.zRange;
34
- let normalAlign = options.normalAlign !== void 0 ? options.normalAlign : true;
35
- //
36
- const mapSize = new Vector2(options.width, options.height);
37
- //
38
- //
39
- console.time('generating impostor foliage');
40
- const geometry = new BufferGeometry();
41
- const _vertices = [];
42
- const _colors = [];
43
- let i = 0;
44
-
45
- const offsetY = 0.00001;
46
-
47
- const color = new Vector4();
48
-
49
- function process(x, y, z, u, v) {
50
- const iX = i++,
51
- iY = i++,
52
- iZ = i++;
53
- _vertices[iX] = x;
54
- _vertices[iY] = y + offsetY;
55
- _vertices[iZ] = z;
56
- //colors
57
- lightMap.sample(u, v, color);
58
- _colors[iX] = color.x / 255;
59
- _colors[iY] = color.y / 255;
60
- _colors[iZ] = color.z / 255;
61
- }
62
-
63
- const sampleTraverser = new SampleTraverser();
64
- sampleTraverser.resolveSpace = true;
65
- sampleTraverser.resolveSpaceSize = density / size;
66
- sampleTraverser.traverse(heightMap, densityMap, density, mapSize, process);
67
-
68
- const vertices = new Float32Array(i);
69
- const colors = new Float32Array(i);
70
- //copy
71
- vertices.set(_vertices, 0);
72
- colors.set(_colors, 0);
73
- console.log("impostor count: " + i);
74
-
75
- geometry.setAttribute('position', new BufferAttribute(vertices, 3));
76
- //if color map is present - use it
77
- geometry.setAttribute('color', new BufferAttribute(colors, 3));
78
-
79
- //bake bounding box and sphere to save computation time
80
- const center = new ThreeVector3(mapSize.x / 2, zRange / 2 - offsetY, mapSize.y / 2);
81
- geometry.boundingSphere = new ThreeSphere(center, center.length());
82
- geometry.boundingBox = new ThreeBox3(new ThreeVector3(0, -zRange / 2 + offsetY, 0), new ThreeVector3(mapSize.x, zRange / 2 + offsetY, mapSize.y));
83
-
84
- const mat = new PointCloudMaterial({
85
- size: size,
86
- map: texture,
87
- blending: NormalBlending,
88
- depthTest: true,
89
- depthWrite: false,
90
- alphaTest: 0.5,
91
- sizeAttenuation: true,
92
- vertexColors: VertexColors,
93
- transparent: true
94
- //
95
- //polygonOffset: true,
96
- //polygonOffsetFactor: -4,
97
- //polygonOffsetUnits: -4
98
- });
99
- mat.color.setHSL(1, 1, 1);
100
-
101
- const mesh = new PointCloud(geometry, mat);
102
- console.timeEnd('generating impostor foliage');
103
- //
104
- return mesh;
105
- };
106
- export default Foliage;