@woosh/meep-engine 2.43.24 → 2.43.26

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.
@@ -29,12 +29,12 @@ async function main() {
29
29
  const index_array = lucy_geom.getIndex().array;
30
30
 
31
31
 
32
+
32
33
  console.time('topo build - bin');
33
34
  // console.profile('topo build - bin');
34
35
  bt_index_geometry_to_topology(mesh, index_array, positions_array);
35
36
  // console.profileEnd('topo build - bin');
36
37
  console.timeEnd('topo build - bin');
37
-
38
38
  //
39
39
  // console.time('topo build - obj');
40
40
  // topoMesh.build(positions_array, index_array);
@@ -44,4 +44,6 @@ export default class Quaternion {
44
44
  toJSON(): any
45
45
 
46
46
  fromJSON(j: any): void
47
+
48
+ asArray(): number[]
47
49
  }
@@ -1609,6 +1609,10 @@ class Quaternion {
1609
1609
  return result;
1610
1610
  }
1611
1611
 
1612
+ asArray() {
1613
+ return [this.x, this.y, this.z, this.w];
1614
+ }
1615
+
1612
1616
  /**
1613
1617
  *
1614
1618
  * @param {Quaternion} other
@@ -12,4 +12,6 @@ export default class Vector1 {
12
12
  isZero(): boolean
13
13
 
14
14
  process(callback: (x) => any): void
15
+
16
+ asArray(): number[]
15
17
  }
@@ -236,6 +236,10 @@ class Vector1 extends Number {
236
236
  array[offset] = this.x;
237
237
  }
238
238
 
239
+ asArray(){
240
+ return [this.x];
241
+ }
242
+
239
243
  /**
240
244
  *
241
245
  * @param {BinaryBuffer} buffer
@@ -35,4 +35,6 @@ export default class Vector2 {
35
35
  distanceTo(other: Vector2): number
36
36
 
37
37
  isZero(): boolean
38
+
39
+ asArray():number[]
38
40
  }
@@ -63,6 +63,14 @@ class Vector2 {
63
63
  array[offset + 1] = this.y;
64
64
  }
65
65
 
66
+ asArray(){
67
+ const r = [];
68
+
69
+ this.writeToArray(r,0);
70
+
71
+ return r;
72
+ }
73
+
66
74
  /**
67
75
  *
68
76
  * @param {number} x
@@ -91,6 +91,8 @@ export default class Vector3 implements Vector3Like {
91
91
 
92
92
  writeToArray(array: number[] | ArrayLike<number>, offset: number): void
93
93
 
94
+ asArray():number[]
95
+
94
96
  static distance(a: Vector3Like, b: Vector3Like): number
95
97
 
96
98
  static dot(a: Vector3Like, b: Vector3Like): number
@@ -57,6 +57,14 @@ class Vector3 {
57
57
  array[offset + 2] = this.z;
58
58
  }
59
59
 
60
+ asArray(){
61
+ const r = [];
62
+
63
+ this.writeToArray(r,0);
64
+
65
+ return r;
66
+ }
67
+
60
68
  /**
61
69
  *
62
70
  * @param {Number} x
@@ -29,5 +29,7 @@ export default class Vector4 {
29
29
 
30
30
  writeToArray(array:ArrayLike<number>, offset:number):void
31
31
 
32
+ asArray(): number[]
33
+
32
34
  threeApplyMatrix4(matrix: Matrix4): void
33
35
  }
@@ -7,6 +7,8 @@ import { assert } from "../../../core/assert.js";
7
7
  * @returns {number}
8
8
  */
9
9
  export function camera_compute_distance_to_fit_length(length, fov) {
10
+ // @see https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html
11
+
10
12
  assert.isNumber(length, 'length');
11
13
  assert.greaterThanOrEqual(length, 0, 'length < 0');
12
14
 
@@ -110,7 +110,6 @@ async function main(engine) {
110
110
  // sg.draw_method = 2;
111
111
  // sg.draw_method = DRAW_METHOD_INSTANCED;
112
112
  // sg.draw_method = random() > 0.5 ? DRAW_METHOD_INSTANCED : 2;
113
- sg.setFlag(ShadedGeometryFlags.DrawMethodLocked);
114
113
  sg.clearFlag(ShadedGeometryFlags.CastShadow | ShadedGeometryFlags.ReceiveShadow);
115
114
 
116
115
  new EntityBuilder()
@@ -1,5 +1,8 @@
1
1
  import {EnginePlugin} from "../../../../../plugin/EnginePlugin";
2
2
 
3
3
  export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
4
-
4
+ /**
5
+ * Higher value will make AO appear darker, lower values will make it lighter
6
+ */
7
+ public intensity: number
5
8
  }
@@ -114,6 +114,22 @@ export class AmbientOcclusionPostProcessEffect extends EnginePlugin {
114
114
  this.__blur = new DepthLimitedBlur({ format: RedFormat, clear_color: 0xFFFFFF });
115
115
  }
116
116
 
117
+ /**
118
+ * Higher value will make AO appear darker, lower values will make it lighter
119
+ * @param {number} v
120
+ */
121
+ set intensity(v) {
122
+ this.__material.uniforms.intensity.value = v;
123
+ }
124
+
125
+ /**
126
+ *
127
+ * @return {number}
128
+ */
129
+ get intensity() {
130
+ return this.__material.uniforms.intensity.value;
131
+ }
132
+
117
133
  /**
118
134
  *
119
135
  * @param {Camera} camera
@@ -91,7 +91,7 @@ export class HierarchicalZBuffer {
91
91
 
92
92
  for (let i = existing_mip_depth; i < mip_depth; i++) {
93
93
 
94
- mips[i] = new WebGLRenderTarget(1, 1, {
94
+ const renderTarget = new WebGLRenderTarget(1, 1, {
95
95
  minFilter: NearestFilter,
96
96
  magFilter: NearestFilter,
97
97
  format: RedFormat,
@@ -104,6 +104,10 @@ export class HierarchicalZBuffer {
104
104
  generateMipmaps: false
105
105
  });
106
106
 
107
+ renderTarget.texture.name = `Hierarchical Z buffer MIP ${i}`;
108
+
109
+ mips[i] = renderTarget;
110
+
107
111
  }
108
112
 
109
113
  }
@@ -58,7 +58,7 @@ function makeShader({ texture, alpha_override, swizzle }) {
58
58
 
59
59
  if (texture_channel_count < 4) {
60
60
  // no override specified, and alpha would be 0, force it to one to make image visible
61
- _swizzle[4] = 1;
61
+ _swizzle[3] = 1;
62
62
  }
63
63
 
64
64
  return new ShaderMaterial({
@@ -83,7 +83,7 @@ function makeShader({ texture, alpha_override, swizzle }) {
83
83
  void main() {
84
84
 
85
85
  vec4 texel = ${sampleTexel(texture, 'tDiffuse', 'vUv')};
86
- gl_FragColor = ${glsl_gen_swizzled_read('texel', swizzle)};
86
+ gl_FragColor = ${glsl_gen_swizzled_read('texel', _swizzle)};
87
87
  }`,
88
88
  uniforms: {
89
89
 
@@ -163,7 +163,6 @@ export function renderSamplerFromTexture({
163
163
  }
164
164
 
165
165
  const render = () => {
166
-
167
166
  const shader = getShader();
168
167
 
169
168
  shader.uniforms.tDiffuse.value = texture;
@@ -186,10 +185,12 @@ export function renderSamplerFromTexture({
186
185
  destination,
187
186
  render,
188
187
  set texture(v) {
188
+ if (v !== texture) {
189
189
 
190
- texture = v;
190
+ texture = v;
191
191
 
192
- getShader().uniforms.tDiffuse.value = v;
192
+ getShader().uniforms.tDiffuse.value = v;
193
+ }
193
194
  }
194
195
  }
195
196
  }
@@ -203,13 +203,17 @@ function print_perf_stats() {
203
203
  function prepare_query_test(hiz, graphics, ecd) {
204
204
 
205
205
  const query = new BatchOcclusionQuery();
206
- query.setSize(64);
206
+ query.setSize(100);
207
207
 
208
208
 
209
209
  const random = seededRandom(42);
210
210
 
211
211
  const row_count = 8;
212
212
 
213
+ /**
214
+ *
215
+ * @type {EntityBuilder[]}
216
+ */
213
217
  const entities = [];
214
218
  const labels = [];
215
219
 
@@ -224,8 +228,11 @@ function prepare_query_test(hiz, graphics, ecd) {
224
228
 
225
229
  mat4.copy(projection, world_inverse);
226
230
  mat4.multiply(projection, camera_projection, projection);
231
+ const aabb = new Float32Array(6);
232
+
233
+ const query_size = query.getSize();
227
234
 
228
- for (let i = 0; i < query.getSize(); i++) {
235
+ for (let i = 0; i < query_size; i++) {
229
236
  const entity = entities[i];
230
237
 
231
238
  if (entity === undefined) {
@@ -236,7 +243,6 @@ function prepare_query_test(hiz, graphics, ecd) {
236
243
  * @type {Mesh}
237
244
  */
238
245
  const mesh = entity.getComponent(Mesh);
239
- const aabb = new Float32Array(6);
240
246
 
241
247
  mesh.bvh.writeToArray(aabb, 0);
242
248
 
@@ -4,7 +4,7 @@ import { max2 } from "../../../../core/math/max2.js";
4
4
  import { assert } from "../../../../core/assert.js";
5
5
 
6
6
  /**
7
- *
7
+ * Build gaussian 2d kernel
8
8
  * @param {number[]} result
9
9
  * @param {number} samplesX
10
10
  * @param {number} samplesY
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.43.24",
8
+ "version": "2.43.26",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",