@woosh/meep-engine 2.33.26 → 2.33.30

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 (54) hide show
  1. package/core/binary/BitSet.js +151 -167
  2. package/core/binary/BitSet.spec.js +99 -1
  3. package/core/binary/ValidatingBitSetWrapper.js +81 -0
  4. package/core/bvh2/aabb3/AABB3.js +3 -10
  5. package/core/cache/Cache.d.ts +4 -2
  6. package/core/cache/Cache.js +5 -2
  7. package/core/collection/HashMap.d.ts +9 -2
  8. package/core/collection/HashSet.d.ts +7 -2
  9. package/core/collection/HashSet.js +7 -2
  10. package/core/collection/array/typed/typed_array_copy.js +1 -1
  11. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +3 -3
  12. package/core/model/ObservedBoolean.d.ts +2 -0
  13. package/core/parser/simple/Token.d.ts +13 -0
  14. package/core/parser/simple/Token.js +61 -27
  15. package/editor/tools/FoliagePaintTool.js +4 -4
  16. package/engine/asset/loaders/GLTFAssetLoader.js +52 -1
  17. package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
  18. package/engine/asset/loaders/image/ImageRGBADataAsset.js +3 -2
  19. package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
  20. package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
  21. package/engine/asset/loaders/image/png/PNG.js +113 -6
  22. package/engine/asset/loaders/image/png/PNGReader.js +5 -0
  23. package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
  24. package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
  25. package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
  26. package/engine/ecs/EntityComponentDataset.js +1 -1
  27. package/engine/ecs/foliage/InstancedFoliage.js +277 -266
  28. package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
  29. package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
  30. package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
  31. package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
  32. package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
  33. package/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
  34. package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +12 -16
  35. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
  36. package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
  37. package/engine/graphics/material/manager/MaterialManager.js +2 -1
  38. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +6 -4
  39. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
  40. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -2
  41. package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +1 -1
  42. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -2
  43. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +3 -4
  44. package/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
  45. package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
  46. package/engine/graphics/render/forward_plus/prototypeLightManager.js +4 -4
  47. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +10 -9
  48. package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
  49. package/engine/graphics/texture/sampler/Sampler2D.js +3 -1
  50. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
  51. package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
  52. package/engine/input/devices/KeyCodes.d.ts +1 -0
  53. package/package.json +1 -1
  54. package/view/minimap/gl/MinimapWorldGL.js +12 -5
@@ -1,7 +1,7 @@
1
1
  import { System } from "../../System.js";
2
2
  import { InstancedFoliage } from "../InstancedFoliage.js";
3
3
  import { Cache } from "../../../../core/cache/Cache.js";
4
- import { Foliage2 } from "./Foliage2.js";
4
+ import { InstancedMeshComponent } from "./InstancedMeshComponent.js";
5
5
  import { guessAssetType } from "../../../asset/guessAssetType.js";
6
6
 
7
7
 
@@ -19,7 +19,7 @@ function cleanupLayer(layerData, renderLayer) {
19
19
 
20
20
  /**
21
21
  *
22
- * @param {FoliageLayer} layer
22
+ * @param {InstancedMeshLayer} layer
23
23
  * @param {AssetManager} assetManager
24
24
  * @returns {Promise<InstancedFoliage>}
25
25
  */
@@ -60,7 +60,7 @@ export function loadFoliageLayer(layer, assetManager) {
60
60
 
61
61
  /**
62
62
  *
63
- * @param {FoliageLayer} layer
63
+ * @param {InstancedMeshLayer} layer
64
64
  * @param {Cache<string, Promise<InstancedFoliage>>} cache
65
65
  * @param {AssetManager} assetManager
66
66
  * @returns {Promise<InstancedFoliage>}
@@ -83,7 +83,7 @@ export class Foliage2System extends System {
83
83
  * @param {AssetManager} assetManager
84
84
  * @param {GraphicsEngine} graphicsEngine
85
85
  * @constructor
86
- * @extends {System.<Foliage2>}
86
+ * @extends {System.<InstancedMeshComponent>}
87
87
  */
88
88
  constructor(assetManager, graphicsEngine) {
89
89
  super();
@@ -96,7 +96,7 @@ export class Foliage2System extends System {
96
96
  */
97
97
  this.renderLayer = null;
98
98
 
99
- this.dependencies = [Foliage2];
99
+ this.dependencies = [InstancedMeshComponent];
100
100
 
101
101
  /**
102
102
  *
@@ -166,7 +166,7 @@ export class Foliage2System extends System {
166
166
 
167
167
  /**
168
168
  *
169
- * @param {Foliage2} foliage
169
+ * @param {InstancedMeshComponent} foliage
170
170
  * @param entity
171
171
  */
172
172
  link(foliage, entity) {
@@ -181,7 +181,7 @@ export class Foliage2System extends System {
181
181
  for (let i = 0; i < layer_count; i++) {
182
182
  /**
183
183
  *
184
- * @type {FoliageLayer}
184
+ * @type {InstancedMeshLayer}
185
185
  */
186
186
  const foliage_layer = layerList.get(i);
187
187
 
@@ -0,0 +1,37 @@
1
+ import List from "../../../../core/collection/list/List.js";
2
+ import { InstancedMeshLayer } from "./InstancedMeshLayer.js";
3
+
4
+
5
+ export class InstancedMeshComponent {
6
+ constructor() {
7
+ /**
8
+ *
9
+ * @type {List<InstancedMeshLayer>}
10
+ * @readonly
11
+ */
12
+ this.layers = new List();
13
+ }
14
+
15
+ toJSON() {
16
+ return this.layers.toJSON();
17
+ }
18
+
19
+ fromJSON(data) {
20
+ this.layers.fromJSON(data, InstancedMeshLayer);
21
+ }
22
+
23
+ dispose() {
24
+
25
+ const layers = this.layers;
26
+ const n = layers.length;
27
+
28
+ for (let i = 0; i < n; i++) {
29
+ const layer = layers.get(i);
30
+
31
+ layer.dispose();
32
+ }
33
+ }
34
+ }
35
+
36
+ InstancedMeshComponent.typeName = "InstancedMeshComponent";
37
+
@@ -1,12 +1,11 @@
1
+ import { InstancedFoliage } from "../InstancedFoliage.js";
1
2
  import ObservedString from "../../../../core/model/ObservedString.js";
2
- import List from "../../../../core/collection/list/List.js";
3
3
  import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
4
- import { InstancedFoliage } from "../InstancedFoliage.js";
4
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
5
5
  import { Base64 } from "../../../../core/binary/Base64.js";
6
6
  import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
7
- import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
8
7
 
9
- export class FoliageLayer {
8
+ export class InstancedMeshLayer {
10
9
  constructor() {
11
10
  /**
12
11
  *
@@ -22,12 +21,6 @@ export class FoliageLayer {
22
21
  */
23
22
  this.modelURL = new ObservedString("");
24
23
 
25
- /**
26
- * @deprecated
27
- * @type {ObservedString}
28
- */
29
- this.dataURL = new ObservedString("");
30
-
31
24
  /**
32
25
  *
33
26
  * @type {ObservedBoolean}
@@ -123,38 +116,3 @@ export class FoliageLayer {
123
116
  this.data.deserialize(buffer);
124
117
  }
125
118
  }
126
-
127
-
128
- export class Foliage2 {
129
- constructor() {
130
- /**
131
- *
132
- * @type {List<FoliageLayer>}
133
- * @readonly
134
- */
135
- this.layers = new List();
136
- }
137
-
138
- toJSON() {
139
- return this.layers.toJSON();
140
- }
141
-
142
- fromJSON(data) {
143
- this.layers.fromJSON(data, FoliageLayer);
144
- }
145
-
146
- dispose() {
147
-
148
- const layers = this.layers;
149
- const n = layers.length;
150
-
151
- for (let i = 0; i < n; i++) {
152
- const layer = layers.get(i);
153
-
154
- layer.dispose();
155
- }
156
- }
157
- }
158
-
159
- Foliage2.typeName = "Foliage2";
160
-
@@ -1,18 +1,19 @@
1
1
  import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClassSerializationAdapter.js";
2
- import { Foliage2, FoliageLayer } from "./Foliage2.js";
2
+ import { InstancedMeshComponent } from "./InstancedMeshComponent.js";
3
+ import { InstancedMeshLayer } from "./InstancedMeshLayer.js";
3
4
 
4
5
  export class InstancedMeshSerializationAdapter extends BinaryClassSerializationAdapter {
5
6
  constructor() {
6
7
  super();
7
8
 
8
- this.klass = Foliage2;
9
+ this.klass = InstancedMeshComponent;
9
10
  this.version = 0;
10
11
  }
11
12
 
12
13
  /**
13
14
  *
14
15
  * @param {BinaryBuffer} buffer
15
- * @param {Foliage2} value
16
+ * @param {InstancedMeshComponent} value
16
17
  */
17
18
  serialize(buffer, value) {
18
19
  value.layers.toBinaryBuffer(buffer);
@@ -21,10 +22,10 @@ export class InstancedMeshSerializationAdapter extends BinaryClassSerializationA
21
22
  /**
22
23
  *
23
24
  * @param {BinaryBuffer} buffer
24
- * @param {Foliage2} value
25
+ * @param {InstancedMeshComponent} value
25
26
  */
26
27
  deserialize(buffer, value) {
27
28
 
28
- value.layers.fromBinaryBuffer(buffer, FoliageLayer);
29
+ value.layers.fromBinaryBuffer(buffer, InstancedMeshLayer);
29
30
  }
30
31
  }
@@ -2,13 +2,14 @@ import EntityBuilder from "../../EntityBuilder.js";
2
2
  import { loadFoliageLayer } from "./Foliage2System.js";
3
3
  import Mesh, { MeshFlags } from "../../../graphics/ecs/mesh/Mesh.js";
4
4
  import { Transform } from "../../transform/Transform.js";
5
- import { Foliage2, FoliageLayer } from "./Foliage2.js";
5
+ import { InstancedMeshComponent } from "./InstancedMeshComponent.js";
6
6
  import { InstancedFoliage } from "../InstancedFoliage.js";
7
7
  import { buildTreeOptimizationTask } from "../../../../core/bvh2/BVHTasks.js";
8
8
  import Task from "../../../../core/process/task/Task.js";
9
9
  import TaskSignal from "../../../../core/process/task/TaskSignal.js";
10
10
  import { countTask, promiseTask } from "../../../../core/process/task/TaskUtils.js";
11
11
  import { assert } from "../../../../core/assert.js";
12
+ import { InstancedMeshLayer } from "./InstancedMeshLayer.js";
12
13
 
13
14
  /**
14
15
  * Convert all existing instanced mesh components to individual Transform+Mesh pairs
@@ -23,7 +24,7 @@ export function convertInstancedMeshComponents2Entities(dataset, assetManager) {
23
24
 
24
25
  /**
25
26
  *
26
- * @param {Foliage2} foliage2
27
+ * @param {InstancedMeshComponent} foliage2
27
28
  * @param entity
28
29
  */
29
30
  function visitFoliageEntities(foliage2, entity) {
@@ -59,11 +60,11 @@ export function convertInstancedMeshComponents2Entities(dataset, assetManager) {
59
60
  entitiesToStrip.push(entity);
60
61
  }
61
62
 
62
- dataset.traverseEntities([Foliage2], visitFoliageEntities);
63
+ dataset.traverseEntities([InstancedMeshComponent], visitFoliageEntities);
63
64
 
64
65
  //remove converted foliage components
65
66
  entitiesToStrip.forEach(function (entity) {
66
- dataset.removeComponentFromEntity(entity, Foliage2);
67
+ dataset.removeComponentFromEntity(entity, InstancedMeshComponent);
67
68
  });
68
69
  }
69
70
 
@@ -125,7 +126,7 @@ export function optimizeIndividualMeshesEntitiesToInstances(dataset, threshold =
125
126
 
126
127
  const tasks = [];
127
128
 
128
- const foliage2 = new Foliage2();
129
+ const foliage2 = new InstancedMeshComponent();
129
130
 
130
131
  const tBuild = new Task({
131
132
  name: "Build Meshes",
@@ -213,7 +214,7 @@ export function optimizeIndividualMeshesEntitiesToInstances(dataset, threshold =
213
214
  cycleFunction: function () {
214
215
 
215
216
  //create foliage layer
216
- const layer = new FoliageLayer();
217
+ const layer = new InstancedMeshLayer();
217
218
 
218
219
  layer.data = instancedFoliage;
219
220
  layer.modelURL.set(modelURL);
@@ -37,7 +37,7 @@ export class BinarySerializationRegistry {
37
37
  * @returns {boolean}
38
38
  */
39
39
  registerAdapter(adapter, className) {
40
- assert.notEqual(adapter, undefined, 'adapter is undefined');
40
+ assert.defined(adapter, 'adapter');
41
41
  assert.ok(adapter.isBinaryClassSerializationAdapter, 'adapter is not a BinaryClassSerializationAdapter');
42
42
 
43
43
  if (className === undefined) {
@@ -5,6 +5,7 @@ import { Cache } from "../../../../../core/cache/Cache.js";
5
5
  import { computeUTF8StringByteSize } from "../../../../../core/primitives/strings/StringUtils.js";
6
6
  import Signal from "../../../../../core/events/signal/Signal.js";
7
7
  import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
8
+ import { copy_Sampler2D_channel_data } from "../../../../graphics/texture/sampler/copy_Sampler2D_channel_data.js";
8
9
 
9
10
  /**
10
11
  *
@@ -107,33 +108,28 @@ export class TerrainLayer {
107
108
  .then(assert => {
108
109
  const image = assert.create();
109
110
 
110
- const s = image.width * image.height;
111
+ const source_item_size = image.itemSize;
111
112
 
112
- const data = image.data;
113
+ const source_data = image.data;
114
+
115
+ // RGB
116
+ const destination_item_size = 3;
113
117
 
114
118
  if (this.diffuse === null || this.diffuse.width !== image.width || this.diffuse.height !== image.height) {
115
119
  // loaded image does not match the side of the layer
116
- this.diffuse = Sampler2D.uint8(3, image.width, image.height);
120
+ this.diffuse = Sampler2D.uint8(destination_item_size, image.width, image.height);
117
121
  }
118
122
 
119
- const layerData = this.diffuse.data;
120
-
121
- // copy RGBA image data into the layer's RGB data
123
+ const source = new Sampler2D(source_data,source_item_size,image.width, image.height);
122
124
 
123
- for (let i = 0; i < s; i++) {
124
- const a4 = i * 4;
125
- const a3 = i * 3;
126
-
127
- layerData[a3] = data[a4];
128
- layerData[a3 + 1] = data[a4 + 1];
129
- layerData[a3 + 2] = data[a4 + 2];
130
- }
125
+ copy_Sampler2D_channel_data(source,this.diffuse);
131
126
 
132
127
  this.onChanged.send0();
133
128
 
134
- const cacheCopy = Sampler2D.uint8(3, image.width, image.height);
129
+ // write to cache
130
+ const cacheCopy = Sampler2D.uint8(destination_item_size, image.width, image.height);
135
131
 
136
- cacheCopy.data.set(layerData);
132
+ cacheCopy.data.set(this.diffuse.data);
137
133
 
138
134
  cache.put(path, cacheCopy);
139
135
 
@@ -9,6 +9,7 @@ import ThreeFactory from "../../three/ThreeFactory.js";
9
9
  import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
10
10
  import { composeCompile } from "../../material/composeCompile.js";
11
11
  import { typed_array_copy } from "../../../../core/collection/array/typed/typed_array_copy.js";
12
+ import { rewriteMaterial } from "./rewriteMaterial.js";
12
13
 
13
14
  /**
14
15
  *
@@ -94,77 +95,6 @@ InstancedMeshGroup.prototype.setGeometry = function (geometry) {
94
95
  };
95
96
 
96
97
 
97
- const SHADER_PREAMBLE = `
98
- attribute vec3 instancePosition;
99
- attribute vec4 instanceRotation;
100
- attribute vec3 instanceScale;
101
-
102
- vec3 instanceTransform( in vec3 position, vec3 T, vec4 R, vec3 S ){
103
- vec3 result = position;
104
-
105
- //applies the scale
106
- result *= S;
107
- //computes the rotation where R is a (vec4) quaternion
108
- result += 2.0 * cross( R.xyz, cross( R.xyz, result ) + R.w * result );
109
- //translates the transformed 'blueprint'
110
- result += T;
111
-
112
- return result;
113
- }
114
-
115
- mat4 getInstanceMatrix(){
116
- vec4 q = instanceRotation;
117
- vec3 s = instanceScale;
118
- vec3 v = instancePosition;
119
-
120
- vec3 q2 = q.xyz + q.xyz;
121
- vec3 a = q.xxx * q2.xyz;
122
- vec3 b = q.yyz * q2.yzz;
123
- vec3 c = q.www * q2.xyz;
124
-
125
- vec3 r0 = vec3( 1.0 - (b.x + b.z) , a.y + c.z , a.z - c.y ) * s.xxx;
126
- vec3 r1 = vec3( a.y - c.z , 1.0 - (a.x + b.z) , b.y + c.x ) * s.yyy;
127
- vec3 r2 = vec3( a.z + c.y , b.y - c.x , 1.0 - (a.x + b.x) ) * s.zzz;
128
-
129
- return mat4(
130
- r0 , 0.0,
131
- r1 , 0.0,
132
- r2 , 0.0,
133
- v , 1.0
134
- );
135
- }\n`;
136
-
137
- function rewriteMaterial(shader) {
138
- const originalVertexShader = shader.vertexShader;
139
-
140
- const newVertexShader = SHADER_PREAMBLE
141
- + originalVertexShader
142
- .replace(
143
- '#include <uv_vertex>',
144
- `
145
- mat4 instanceMatrix = getInstanceMatrix();
146
- #include <uv_vertex>
147
- `
148
- )
149
- .replace(
150
- '#include <begin_vertex>',
151
- `
152
- vec3 transformed = ( instanceMatrix * vec4(position,1.0) ).xyz;
153
- `
154
- )
155
- .replace(
156
- '#include <beginnormal_vertex>',
157
- `
158
- vec3 objectNormal = mat3( instanceMatrix ) * vec3( normal );
159
- #ifdef USE_TANGENT
160
- vec3 objectTangent = vec3( tangent.xyz );
161
- #endif
162
- `
163
- );
164
-
165
- shader.vertexShader = newVertexShader;
166
- }
167
-
168
98
  /**
169
99
  *
170
100
  * @param {THREE.Material} sourceMaterial
@@ -332,7 +262,19 @@ InstancedMeshGroup.prototype.add = function (reference) {
332
262
  * @param {*} [thisArg]
333
263
  */
334
264
  InstancedMeshGroup.prototype.traverseReferences = function (visitor, thisArg) {
335
- this.indices.forEach(visitor, thisArg);
265
+ const indices = this.indices;
266
+ const index_count = indices.length;
267
+
268
+ for (let i = 0; i < index_count; i++) {
269
+ const index = indices[i];
270
+
271
+ if (index === undefined) {
272
+ // unoccupied
273
+ continue;
274
+ }
275
+
276
+ visitor.call(thisArg, index, i);
277
+ }
336
278
  };
337
279
 
338
280
  /**
@@ -0,0 +1,70 @@
1
+ const SHADER_PREAMBLE = `
2
+ attribute vec3 instancePosition;
3
+ attribute vec4 instanceRotation;
4
+ attribute vec3 instanceScale;
5
+
6
+ vec3 instanceTransform( in vec3 position, vec3 T, vec4 R, vec3 S ){
7
+ vec3 result = position;
8
+
9
+ //applies the scale
10
+ result *= S;
11
+ //computes the rotation where R is a (vec4) quaternion
12
+ result += 2.0 * cross( R.xyz, cross( R.xyz, result ) + R.w * result );
13
+ //translates the transformed 'blueprint'
14
+ result += T;
15
+
16
+ return result;
17
+ }
18
+
19
+ mat4 getInstanceMatrix(){
20
+ vec4 q = instanceRotation;
21
+ vec3 s = instanceScale;
22
+ vec3 v = instancePosition;
23
+
24
+ vec3 q2 = q.xyz + q.xyz;
25
+ vec3 a = q.xxx * q2.xyz;
26
+ vec3 b = q.yyz * q2.yzz;
27
+ vec3 c = q.www * q2.xyz;
28
+
29
+ vec3 r0 = vec3( 1.0 - (b.x + b.z) , a.y + c.z , a.z - c.y ) * s.xxx;
30
+ vec3 r1 = vec3( a.y - c.z , 1.0 - (a.x + b.z) , b.y + c.x ) * s.yyy;
31
+ vec3 r2 = vec3( a.z + c.y , b.y - c.x , 1.0 - (a.x + b.x) ) * s.zzz;
32
+
33
+ return mat4(
34
+ r0 , 0.0,
35
+ r1 , 0.0,
36
+ r2 , 0.0,
37
+ v , 1.0
38
+ );
39
+ }\n`;
40
+
41
+ export function rewriteMaterial(shader) {
42
+ const originalVertexShader = shader.vertexShader;
43
+
44
+ const newVertexShader = SHADER_PREAMBLE
45
+ + originalVertexShader
46
+ .replace(
47
+ '#include <uv_vertex>',
48
+ `
49
+ mat4 instanceMatrix = getInstanceMatrix();
50
+ #include <uv_vertex>
51
+ `
52
+ )
53
+ .replace(
54
+ '#include <begin_vertex>',
55
+ `
56
+ vec3 transformed = ( instanceMatrix * vec4(position,1.0) ).xyz;
57
+ `
58
+ )
59
+ .replace(
60
+ '#include <beginnormal_vertex>',
61
+ `
62
+ vec3 objectNormal = mat3( instanceMatrix ) * vec3( normal );
63
+ #ifdef USE_TANGENT
64
+ vec3 objectTangent = vec3( tangent.xyz );
65
+ #endif
66
+ `
67
+ );
68
+
69
+ shader.vertexShader = newVertexShader;
70
+ }
@@ -14,7 +14,8 @@ export class MaterialManager {
14
14
  */
15
15
  this.__library = new HashMap({
16
16
  keyHashFunction: computeMaterialHash,
17
- keyEqualityFunction: computeMaterialEquality
17
+ keyEqualityFunction: computeMaterialEquality,
18
+ capacity: 1024
18
19
  });
19
20
 
20
21
  /**
@@ -237,8 +237,8 @@ export class AttributeDataTexture {
237
237
  /**
238
238
  *
239
239
  * @param {number} slot
240
- * @param {number[]} indices
241
- * @param {number[]} source
240
+ * @param {number[]} indices triangle indices (index buffer)
241
+ * @param {number[]} source vertex data
242
242
  */
243
243
  write_slot_from_indexed(slot, indices, source) {
244
244
  assert.isNonNegativeInteger(slot, 'index');
@@ -289,8 +289,10 @@ export class AttributeDataTexture {
289
289
  const start_index = slot_size * index;
290
290
  const end_index = slot_size * (index + 1);
291
291
 
292
- this.__texture.image.data.fill(0, start_index, end_index);
293
- this.__texture.needsUpdate = true;
292
+ const texture = this.__texture;
293
+
294
+ texture.image.data.fill(0, start_index, end_index);
295
+ texture.needsUpdate = true;
294
296
  }
295
297
 
296
298
  /**
@@ -11,7 +11,6 @@ import Signal from "../../../../../core/events/signal/Signal.js";
11
11
  import { ATTRIBUTE_NAME_ADDRESS, ATTRIBUTE_NAME_TRANSFORM } from "./shader/constants.js";
12
12
  import { shader_rewrite_standard } from "./shader/shader_rewrite_standard.js";
13
13
 
14
-
15
14
  export class ThreeInstancedAdapter {
16
15
  /**
17
16
  *
@@ -79,7 +78,6 @@ export class ThreeInstancedAdapter {
79
78
  const position_buffer = new BufferAttribute(new Uint8Array(MICRON_PATCH_SIZE_MAX * 3 * 3), 3, false);
80
79
 
81
80
 
82
-
83
81
  position_buffer.setUsage(StaticReadUsage);
84
82
 
85
83
  geo.setAttribute('position', position_buffer);
@@ -192,8 +192,7 @@ export class ShaderManager {
192
192
  }
193
193
  };
194
194
 
195
- // debugAtlas(this.parameterSheet.atlas, { scale: new Vector2(16, 16) });
196
- // debugAtlas(this.spriteAtlas.atlas, { scale: new Vector2(0.5, 0.5) });
195
+ // debugAtlas(this.spriteAtlas.atlas, { scale: new Vector2(1, 1) });
197
196
  }
198
197
 
199
198
  /**
@@ -5,7 +5,7 @@ import { TextureAtlasDebugger } from "../../../../texture/atlas/TextureAtlasDebu
5
5
  * @param {TextureAtlas} atlas
6
6
  * @param {*} options
7
7
  */
8
- function debugAtlas(atlas, options) {
8
+ export function debugAtlas(atlas, options) {
9
9
 
10
10
  const spriteAtlasDebugger = new TextureAtlasDebugger(atlas, options);
11
11
 
@@ -77,6 +77,7 @@ import ButtonView from "../../../../../../../view/elements/button/ButtonView.js"
77
77
  import { UnitSphereShape3D } from "../../../../../../../core/geom/3d/shape/UnitSphereShape3D.js";
78
78
  import TopDownCameraController from "../../../../../ecs/camera/topdown/TopDownCameraController.js";
79
79
  import { randomFloatBetween } from "../../../../../../../core/math/random/randomFloatBetween.js";
80
+ import { MicronRenderPlugin } from "../../../../../micron/plugin/MicronRenderPlugin.js";
80
81
 
81
82
  const engineHarness = new EngineHarness();
82
83
 
@@ -130,7 +131,7 @@ function makeConfig(engine) {
130
131
 
131
132
 
132
133
  // Plugins
133
- // config.addPlugin(MicronRenderPlugin);
134
+ config.addPlugin(MicronRenderPlugin);
134
135
 
135
136
 
136
137
  // Knowledge
@@ -306,6 +307,7 @@ async function sample_scene_0(engine) {
306
307
 
307
308
  // load_model('moicon/06_04_hapro/00-environment/model.gltf', -0.1);
308
309
  load_model_s('moicon/06_04_hapro/05-ground-floor/model.gltf');
310
+ load_model_s('C:/git/moh/app/moicon/06_04_hapro/08-clickable-assets-new/model.gltf');
309
311
  // load_model('moicon/06_04_hapro/02-bearers/model.gltf');
310
312
  // load_model('moicon/06_04_hapro/04-1st-floor/model.gltf');
311
313
 
@@ -607,7 +609,8 @@ async function main(engine) {
607
609
 
608
610
  engine.graphics.renderer.setClearColor('rgba(99,99,99,1)');
609
611
 
610
- await sample_scene_nam(engine);
612
+ // await sample_scene_nam(engine);
613
+ await sample_scene_0(engine);
611
614
  }
612
615
 
613
616
  /**
@@ -1,4 +1,3 @@
1
- import { max2 } from "../../../../../../core/math/max2.js";
2
1
  import { EnginePlugin } from "../../../../../plugin/EnginePlugin.js";
3
2
  import {
4
3
  LinearFilter,
@@ -161,9 +160,9 @@ export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
161
160
  uniforms.bias.value = 0.5;
162
161
  uniforms.intensity.value = 0.18;
163
162
 
164
- const depth_range = far - near;
165
-
166
- uniforms.scale.value = 5 * max2(1, depth_range / 30);
163
+ // scale is divided by camera far in the shader, we unbias it here
164
+ // TODO remove this term from the shader
165
+ uniforms.scale.value = far * 0.25;
167
166
 
168
167
  uniforms.kernelRadius.value = 30;
169
168
  uniforms.minResolution.value = 0;
@@ -36,7 +36,7 @@ const f_shader = `
36
36
 
37
37
  uniform sampler2D t_heatmap_lookup;
38
38
 
39
- uniform vec2 resolution;
39
+ uniform vec2 fp_resolution;
40
40
 
41
41
  uniform mat4 projectionMatrix;
42
42
 
@@ -79,7 +79,7 @@ const f_shader = `
79
79
 
80
80
  void main(){
81
81
 
82
- vec3 clip_v = vec3(gl_FragCoord.xy / resolution, convert_depth_to_linear( gl_FragCoord.z));
82
+ vec3 clip_v = vec3(gl_FragCoord.xy / fp_resolution, convert_depth_to_linear( gl_FragCoord.z));
83
83
 
84
84
  ivec3 v3_cluster_resolution = textureSize(fp_t_light_tiles, 0);
85
85
  ivec3 v3_cluster_position = ivec3( ( 1.0 - clip_v.x) * float(v3_cluster_resolution.x), clip_v.y*float(v3_cluster_resolution.y), (clip_v.z)*float(v3_cluster_resolution.z) );
@@ -119,7 +119,7 @@ export class FPlusDebugMaterial extends ShaderMaterial {
119
119
  type: 'f',
120
120
  value: 0
121
121
  },
122
- resolution: {
122
+ fp_resolution: {
123
123
  type: 'v2',
124
124
  value: new Vector2()
125
125
  },
@@ -29,7 +29,7 @@ export class ForwardPlusThreeMaterial extends ShaderMaterial {
29
29
  type: 'f',
30
30
  value: 0
31
31
  },
32
- resolution: {
32
+ fp_resolution: {
33
33
  type: 'v2',
34
34
  value: new Vector2()
35
35
  }