@woosh/meep-engine 2.33.63 → 2.33.64

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.
@@ -7,38 +7,6 @@ import Mesh from "../../graphics/ecs/mesh/Mesh.js";
7
7
  import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
8
8
  import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
9
9
 
10
- /**
11
- * @readonly
12
- * @enum {number}
13
- */
14
- const WaitingType = {
15
- Entity: 0,
16
- Socket: 1,
17
- Mesh: 2,
18
- Transform: 3
19
- };
20
-
21
- class WaitingEntry {
22
- /**
23
- *
24
- * @param {number} entity
25
- * @param {WaitingType} type
26
- */
27
- constructor(entity, type) {
28
- /**
29
- *
30
- * @type {number}
31
- */
32
- this.entity = entity;
33
- /**
34
- *
35
- * @type {WaitingType}
36
- */
37
- this.type = type;
38
- }
39
- }
40
-
41
-
42
10
  export class AttachmentSystem extends System {
43
11
  constructor() {
44
12
  super();
@@ -315,17 +283,10 @@ export class AttachmentSystem extends System {
315
283
  }
316
284
  }
317
285
 
318
- /**
319
- *
320
- * @param {number} entity
321
- * @private
322
- */
323
- __update_entity(entity) {
324
- const bindings = this.parentBindingIndex.get(entity);
286
+ __updateAll() {
287
+ for (const [entity, bindings] of this.parentBindingIndex) {
325
288
 
326
- if (bindings !== undefined) {
327
289
  const n = bindings.length;
328
-
329
290
  for (let i = 0; i < n; i++) {
330
291
  const binding = bindings[i];
331
292
 
@@ -334,15 +295,6 @@ export class AttachmentSystem extends System {
334
295
  }
335
296
  }
336
297
 
337
- /**
338
- *
339
- * @param {Mesh} mesh
340
- * @param {number} entity
341
- */
342
- visitComponent(mesh, entity) {
343
- this.__update_entity(entity);
344
- }
345
-
346
298
  update(timeDelta) {
347
299
  //process wait queue
348
300
  this.processWaiting();
@@ -355,6 +307,6 @@ export class AttachmentSystem extends System {
355
307
  return;
356
308
  }
357
309
 
358
- ecd.traverseComponents(Attachment, this.visitComponent, this);
310
+ this.__updateAll();
359
311
  }
360
312
  }
@@ -0,0 +1,8 @@
1
+ import {DataType} from "../../../core/parser/simple/DataType";
2
+
3
+ export class AttributeSpec {
4
+ readonly name: string
5
+ readonly type: DataType
6
+ readonly itemSize: number
7
+ readonly normalized: boolean
8
+ }
@@ -0,0 +1,15 @@
1
+ import {AttributeSpec} from "./AttributeSpec";
2
+
3
+ export class VertexDataSpec {
4
+ readonly attributes: AttributeSpec[]
5
+
6
+ getAttributeByName(name: string): AttributeSpec | undefined
7
+
8
+ add(attribute: AttributeSpec): this
9
+
10
+ setAttributes(attributes: AttributeSpec[]): void
11
+
12
+ equals(other: VertexDataSpec): boolean
13
+
14
+ hash(): number
15
+ }
@@ -0,0 +1,39 @@
1
+ import { BufferAttribute } from "three";
2
+
3
+
4
+ /**
5
+ *
6
+ * @param {THREE.InterleavedBufferAttribute|THREE.BufferAttribute} source_attribute
7
+ * @returns {THREE.BufferAttribute}
8
+ */
9
+ export function deinterleaveBufferAttribute(source_attribute) {
10
+ if (source_attribute.isInterleavedBufferAttribute !== true && source_attribute.isBufferAttribute) {
11
+ return source_attribute;
12
+ }
13
+
14
+ const source_data = source_attribute.data;
15
+ const source_data_array = source_data.array;
16
+ const stride = source_data.stride;
17
+
18
+ const item_count = source_attribute.count;
19
+ const itemSize = source_attribute.itemSize;
20
+ const array_size = item_count * itemSize;
21
+
22
+ const offset = source_attribute.offset;
23
+
24
+ const destination_array = new source_data_array.constructor(array_size);
25
+
26
+ const attribute = new BufferAttribute(destination_array, itemSize);
27
+
28
+ attribute.normalized = source_attribute.normalized;
29
+ attribute.name = source_attribute.name;
30
+
31
+ // copy data
32
+ for (let i = 0; i < item_count; i++) {
33
+ for (let j = 0; j < itemSize; j++) {
34
+ destination_array[i * itemSize + j] = source_data_array[i * stride + offset + j];
35
+ }
36
+ }
37
+
38
+ return attribute;
39
+ }
@@ -0,0 +1,50 @@
1
+ import { BufferGeometry } from "three";
2
+ import { deinterleaveBufferAttribute } from "./deinterleaveBufferAttribute.js";
3
+
4
+ /**
5
+ *
6
+ * @param {THREE.BufferGeometry} geometry
7
+ * @returns {THREE.BufferGeometry}
8
+ */
9
+ export function deinterleaveBufferGeometry(geometry) {
10
+ const result = new BufferGeometry();
11
+
12
+ if (geometry.getIndex() !== null) {
13
+ result.setIndex(deinterleaveBufferAttribute(geometry.getIndex()));
14
+ }
15
+
16
+ for (const attribute_key in geometry.attributes) {
17
+ const source_attribute = geometry.attributes[attribute_key];
18
+
19
+ result.setAttribute(attribute_key, deinterleaveBufferAttribute(source_attribute));
20
+ }
21
+
22
+ // copy other bits
23
+ result.name = geometry.name;
24
+
25
+ result.morphTargetsRelative = geometry.morphTargetsRelative;
26
+
27
+ for (const attribute_key in geometry.morphAttributes) {
28
+ const source_attributes = geometry.morphAttributes[attribute_key];
29
+
30
+ const result_attributes = [];
31
+
32
+ result.morphAttributes[attribute_key] = result_attributes;
33
+
34
+ for (let i = 0; i < source_attributes.length; i++) {
35
+ const source_attribute = source_attributes[i];
36
+ result_attributes[i] = deinterleaveBufferAttribute(source_attribute);
37
+ }
38
+ }
39
+
40
+ result.groups = geometry.groups.slice();
41
+
42
+
43
+ result.boundingBox = geometry.boundingBox !== null ? geometry.boundingBox.clone() : null;
44
+ result.boundingSphere = geometry.boundingSphere !== null ? geometry.boundingSphere.clone() : null;
45
+ result.drawRange.start = geometry.drawRange.start;
46
+ result.drawRange.count = geometry.drawRange.count;
47
+ result.userData = JSON.parse(JSON.stringify(geometry.userData));
48
+
49
+ return result;
50
+ }
@@ -12,6 +12,7 @@ import { expandConnectivityByLocality } from "../../../../core/geom/3d/topology/
12
12
  import { build_geometry_info } from "./build_geometry_info.js";
13
13
  import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.js";
14
14
  import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compute_buffer_geometry_byte_size.js";
15
+ import { deinterleaveBufferGeometry } from "../../geometry/buffered/deinterleaveBufferGeometry.js";
15
16
 
16
17
  /**
17
18
  * Returns current time in milliseconds
@@ -105,11 +106,13 @@ const PRINT_VERBOSE_STATS = false;
105
106
  * @returns {MicronGeometry}
106
107
  */
107
108
  export async function buildMicronGeometryFromBufferGeometry(input) {
109
+ const source_geometry = deinterleaveBufferGeometry(input);
110
+
108
111
  // build topology representation
109
112
  const topoMesh = new TopoMesh();
110
113
 
111
- const position_attribute = input.getAttribute("position");
112
- const index_attribute = input.index;
114
+ const position_attribute = source_geometry.getAttribute("position");
115
+ const index_attribute = source_geometry.index;
113
116
 
114
117
  const face_index_array = index_attribute.array;
115
118
  const vertex_position_array = position_attribute.array;
@@ -183,18 +186,18 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
183
186
 
184
187
  const r = new MicronGeometry();
185
188
 
186
- r.proxy = input; // TODO use r.buildProxy(1) instead
189
+ r.proxy = source_geometry; // TODO use r.buildProxy(1) instead
187
190
 
188
191
  r.source_triangle_count = index_attribute.count / 3;
189
- r.source_vertex_count = input.getAttribute('position').count;
190
- r.source_byte_size = compute_buffer_geometry_byte_size(input);
192
+ r.source_vertex_count = source_geometry.getAttribute('position').count;
193
+ r.source_byte_size = compute_buffer_geometry_byte_size(source_geometry);
191
194
 
192
195
  // console.time('build geometry');
193
196
 
194
- const vertex_attributes = attributes_from_buffer_geometry(input);
197
+ const vertex_attributes = attributes_from_buffer_geometry(source_geometry);
195
198
 
196
199
  r.vertex_spec.setAttributes(vertex_attributes);
197
- r.root = compilePatchGraph(root, input, r.vertex_spec);
200
+ r.root = compilePatchGraph(root, source_geometry, r.vertex_spec);
198
201
 
199
202
  r.initialize();
200
203
 
@@ -1,5 +1,9 @@
1
1
  import {BufferGeometry} from "three";
2
+ import {VertexDataSpec} from "../../geometry/VertexDataSpec";
2
3
 
3
4
  export class MicronGeometry {
5
+ vertex_spec: VertexDataSpec
4
6
  public proxy: BufferGeometry
7
+
8
+ initialize(): void
5
9
  }
@@ -83,6 +83,14 @@ export class MeshInstance {
83
83
 
84
84
  }
85
85
 
86
+ /**
87
+ *
88
+ * @param {GPURenderPassEncoder} pass
89
+ */
90
+ preparePass(pass) {
91
+
92
+ }
93
+
86
94
  /**
87
95
  *
88
96
  * @param {GPURenderPassEncoder} pass
@@ -94,6 +102,7 @@ export class MeshInstance {
94
102
 
95
103
  pass.setVertexBuffer(0, this.vertex_buffer);
96
104
  pass.setIndexBuffer(this.index_buffer, 'uint32');
105
+
97
106
  pass.drawIndexed(this.geometry.getIndex().array.length);
98
107
  }
99
108
  }
@@ -323,7 +323,7 @@ const init = async ({ canvasRef, gui }) => {
323
323
  };
324
324
  const settings = {
325
325
  mode: 'rendering',
326
- numLights: 128,
326
+ numLights:1,
327
327
  };
328
328
  const configUniformBuffer = (() => {
329
329
  const buffer = device.createBuffer({
@@ -541,7 +541,7 @@ const init = async ({ canvasRef, gui }) => {
541
541
  gBufferPass.setPipeline(writeGBuffersPipeline);
542
542
  gBufferPass.setBindGroup(0, sceneUniformBindGroup);
543
543
 
544
- m_instance.draw(gBufferPass);
544
+ m_instance.draw(gBufferPass);
545
545
 
546
546
  gBufferPass.endPass();
547
547
  }
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.33.63",
8
+ "version": "2.33.64",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",
@@ -1,3 +0,0 @@
1
- /**
2
- * Created by Alex on 13/06/2016.
3
- */