matrix-engine-wgpu 1.2.10 → 1.2.12
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 +1 -1
- package/src/engine/mesh-obj.js +598 -594
- package/src/physics/matrix-ammo.js +24 -1
- package/src/world.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matrix-engine-wgpu",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "+HOTFIX raycast, webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
package/src/engine/mesh-obj.js
CHANGED
|
@@ -8,598 +8,602 @@ import {degToRad, genName, LOG_FUNNY_SMALL} from './utils';
|
|
|
8
8
|
// import {checkingProcedure, checkingRay, touchCoordinate} from './raycast';
|
|
9
9
|
|
|
10
10
|
export default class MEMeshObj {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
11
|
+
constructor(canvas, device, context, o) {
|
|
12
|
+
if(typeof o.name === 'undefined') o.name = genName(9);
|
|
13
|
+
if(typeof o.raycast === 'undefined') {
|
|
14
|
+
this.raycast = {
|
|
15
|
+
enabled: false,
|
|
16
|
+
radius: 2
|
|
17
|
+
};
|
|
18
|
+
} else {
|
|
19
|
+
this.raycast = o.raycast;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.name = o.name;
|
|
23
|
+
this.done = false;
|
|
24
|
+
this.device = device;
|
|
25
|
+
this.context = context;
|
|
26
|
+
this.entityArgPass = o.entityArgPass;
|
|
27
|
+
|
|
28
|
+
// Mesh stuff
|
|
29
|
+
this.mesh = o.mesh;
|
|
30
|
+
this.mesh.uvs = this.mesh.textures;
|
|
31
|
+
console.log(`%c Mesh loaded: ${o.name}`, LOG_FUNNY_SMALL);
|
|
32
|
+
|
|
33
|
+
this.inputHandler = createInputHandler(window, canvas);
|
|
34
|
+
this.cameras = o.cameras;
|
|
35
|
+
|
|
36
|
+
this.mainCameraParams = {
|
|
37
|
+
type: o.mainCameraParams.type,
|
|
38
|
+
responseCoef: o.mainCameraParams.responseCoef
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// touchCoordinate.enabled = true;
|
|
42
|
+
|
|
43
|
+
this.lastFrameMS = 0;
|
|
44
|
+
this.texturesPaths = [];
|
|
45
|
+
o.texturesPaths.forEach((t) => {this.texturesPaths.push(t)})
|
|
46
|
+
|
|
47
|
+
this.presentationFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
48
|
+
|
|
49
|
+
this.position = new Position(o.position.x, o.position.y, o.position.z);
|
|
50
|
+
this.rotation = new Rotation(o.rotation.x, o.rotation.y, o.rotation.z);
|
|
51
|
+
this.rotation.rotationSpeed.x = o.rotationSpeed.x;
|
|
52
|
+
this.rotation.rotationSpeed.y = o.rotationSpeed.y;
|
|
53
|
+
this.rotation.rotationSpeed.z = o.rotationSpeed.z;
|
|
54
|
+
this.scale = o.scale;
|
|
55
|
+
|
|
56
|
+
this.runProgram = () => {
|
|
57
|
+
return new Promise(async (resolve) => {
|
|
58
|
+
this.shadowDepthTextureSize = 1024;
|
|
59
|
+
const aspect = canvas.width / canvas.height;
|
|
60
|
+
this.projectionMatrix = mat4.perspective((2 * Math.PI) / 5, aspect, 1, 2000.0);
|
|
61
|
+
this.modelViewProjectionMatrix = mat4.create();
|
|
62
|
+
// console.log('cube added texturesPaths: ', this.texturesPaths)
|
|
63
|
+
this.loadTex0(this.texturesPaths, device).then(() => {
|
|
64
|
+
// console.log('loaded tex buffer for mesh:', this.texture0)
|
|
65
|
+
resolve()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.runProgram().then(() => {
|
|
71
|
+
const aspect = canvas.width / canvas.height;
|
|
72
|
+
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
73
|
+
this.context.configure({
|
|
74
|
+
device: this.device,
|
|
75
|
+
format: presentationFormat,
|
|
76
|
+
alphaMode: 'premultiplied',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Create the model vertex buffer.
|
|
80
|
+
this.vertexBuffer = this.device.createBuffer({
|
|
81
|
+
size: this.mesh.vertices.length * Float32Array.BYTES_PER_ELEMENT,
|
|
82
|
+
usage: GPUBufferUsage.VERTEX,
|
|
83
|
+
mappedAtCreation: true,
|
|
84
|
+
});
|
|
85
|
+
{
|
|
86
|
+
// const mapping = new Float32Array(this.vertexBuffer.getMappedRange());
|
|
87
|
+
// // for(let i = 0;i < this.mesh.vertices.length;++i) {
|
|
88
|
+
// // mapping.set(this.mesh.vertices[i], 6 * i);
|
|
89
|
+
// // mapping.set(this.mesh.normals[i], 6 * i + 3);
|
|
90
|
+
// // }
|
|
91
|
+
// this.vertexBuffer.unmap();
|
|
92
|
+
new Float32Array(this.vertexBuffer.getMappedRange()).set(this.mesh.vertices);
|
|
93
|
+
this.vertexBuffer.unmap();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// NIDZA TEST SECOUND BUFFER
|
|
97
|
+
// Create the model vertex buffer.
|
|
98
|
+
this.vertexNormalsBuffer = this.device.createBuffer({
|
|
99
|
+
size: this.mesh.vertexNormals.length * Float32Array.BYTES_PER_ELEMENT,
|
|
100
|
+
usage: GPUBufferUsage.VERTEX,
|
|
101
|
+
mappedAtCreation: true,
|
|
102
|
+
});
|
|
103
|
+
{
|
|
104
|
+
new Float32Array(this.vertexNormalsBuffer.getMappedRange()).set(this.mesh.vertexNormals);
|
|
105
|
+
this.vertexNormalsBuffer.unmap();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.vertexTexCoordsBuffer = this.device.createBuffer({
|
|
109
|
+
size: this.mesh.textures.length * Float32Array.BYTES_PER_ELEMENT,
|
|
110
|
+
usage: GPUBufferUsage.VERTEX,
|
|
111
|
+
mappedAtCreation: true,
|
|
112
|
+
});
|
|
113
|
+
{
|
|
114
|
+
new Float32Array(this.vertexTexCoordsBuffer.getMappedRange()).set(this.mesh.textures);
|
|
115
|
+
this.vertexTexCoordsBuffer.unmap();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Create the model index buffer.
|
|
119
|
+
this.indexCount = this.mesh.indices.length;
|
|
120
|
+
this.indexBuffer = this.device.createBuffer({
|
|
121
|
+
size: this.indexCount * Uint16Array.BYTES_PER_ELEMENT,
|
|
122
|
+
usage: GPUBufferUsage.INDEX,
|
|
123
|
+
mappedAtCreation: true,
|
|
124
|
+
});
|
|
125
|
+
{
|
|
126
|
+
// const mapping = new Uint16Array(this.indexBuffer.getMappedRange());
|
|
127
|
+
// for(let i = 0;i < this.mesh.indices.length;++i) {
|
|
128
|
+
// mapping.set(this.mesh.indices[i], i);
|
|
129
|
+
// }
|
|
130
|
+
new Uint16Array(this.indexBuffer.getMappedRange()).set(this.mesh.indices);
|
|
131
|
+
this.indexBuffer.unmap();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Create the depth texture for rendering/sampling the shadow map.
|
|
135
|
+
this.shadowDepthTexture = this.device.createTexture({
|
|
136
|
+
size: [this.shadowDepthTextureSize, this.shadowDepthTextureSize, 1],
|
|
137
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
138
|
+
format: 'depth32float',
|
|
139
|
+
});
|
|
140
|
+
this.shadowDepthTextureView = this.shadowDepthTexture.createView();
|
|
141
|
+
|
|
142
|
+
// Create some common descriptors used for both the shadow pipeline
|
|
143
|
+
// and the color rendering pipeline.
|
|
144
|
+
this.vertexBuffers = [
|
|
145
|
+
{
|
|
146
|
+
arrayStride: Float32Array.BYTES_PER_ELEMENT * 3,
|
|
147
|
+
attributes: [
|
|
148
|
+
{
|
|
149
|
+
// position
|
|
150
|
+
shaderLocation: 0,
|
|
151
|
+
offset: 0,
|
|
152
|
+
format: "float32x3",
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
arrayStride: Float32Array.BYTES_PER_ELEMENT * 3,
|
|
158
|
+
attributes: [
|
|
159
|
+
{
|
|
160
|
+
// normal
|
|
161
|
+
shaderLocation: 1,
|
|
162
|
+
offset: 0,
|
|
163
|
+
format: "float32x3",
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
arrayStride: Float32Array.BYTES_PER_ELEMENT * 2,
|
|
169
|
+
attributes: [
|
|
170
|
+
{
|
|
171
|
+
// uvs
|
|
172
|
+
shaderLocation: 2,
|
|
173
|
+
offset: 0,
|
|
174
|
+
format: "float32x2",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
const primitive = {
|
|
181
|
+
topology: 'triangle-list',
|
|
182
|
+
cullMode: 'back',
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this.uniformBufferBindGroupLayout = this.device.createBindGroupLayout({
|
|
186
|
+
entries: [
|
|
187
|
+
{
|
|
188
|
+
binding: 0,
|
|
189
|
+
visibility: GPUShaderStage.VERTEX,
|
|
190
|
+
buffer: {
|
|
191
|
+
type: 'uniform',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
this.shadowPipeline = this.device.createRenderPipeline({
|
|
198
|
+
layout: this.device.createPipelineLayout({
|
|
199
|
+
bindGroupLayouts: [
|
|
200
|
+
this.uniformBufferBindGroupLayout,
|
|
201
|
+
this.uniformBufferBindGroupLayout,
|
|
202
|
+
],
|
|
203
|
+
}),
|
|
204
|
+
vertex: {
|
|
205
|
+
module: this.device.createShaderModule({
|
|
206
|
+
code: vertexShadowWGSL,
|
|
207
|
+
}),
|
|
208
|
+
buffers: this.vertexBuffers,
|
|
209
|
+
},
|
|
210
|
+
depthStencil: {
|
|
211
|
+
depthWriteEnabled: true,
|
|
212
|
+
depthCompare: 'less',
|
|
213
|
+
format: 'depth32float',
|
|
214
|
+
},
|
|
215
|
+
primitive,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Create a bind group layout which holds the scene uniforms and
|
|
219
|
+
// the texture+sampler for depth. We create it manually because the WebPU
|
|
220
|
+
// implementation doesn't infer this from the shader (yet).
|
|
221
|
+
this.bglForRender = this.device.createBindGroupLayout({
|
|
222
|
+
entries: [
|
|
223
|
+
{
|
|
224
|
+
binding: 0,
|
|
225
|
+
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
226
|
+
buffer: {
|
|
227
|
+
type: 'uniform',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
binding: 1,
|
|
232
|
+
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
233
|
+
texture: {
|
|
234
|
+
sampleType: 'depth',
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
binding: 2,
|
|
239
|
+
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
240
|
+
sampler: {
|
|
241
|
+
type: 'comparison',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
binding: 3,
|
|
246
|
+
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
247
|
+
texture: {
|
|
248
|
+
sampleType: 'float',
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
binding: 4,
|
|
253
|
+
visibility: GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT,
|
|
254
|
+
sampler: {
|
|
255
|
+
type: 'filtering',
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
this.pipeline = this.device.createRenderPipeline({
|
|
262
|
+
layout: this.device.createPipelineLayout({
|
|
263
|
+
bindGroupLayouts: [this.bglForRender, this.uniformBufferBindGroupLayout],
|
|
264
|
+
}),
|
|
265
|
+
vertex: {
|
|
266
|
+
module: this.device.createShaderModule({
|
|
267
|
+
code: vertexWGSL,
|
|
268
|
+
}),
|
|
269
|
+
buffers: this.vertexBuffers,
|
|
270
|
+
},
|
|
271
|
+
fragment: {
|
|
272
|
+
module: this.device.createShaderModule({
|
|
273
|
+
code: fragmentWGSL,
|
|
274
|
+
}),
|
|
275
|
+
targets: [
|
|
276
|
+
{
|
|
277
|
+
format: presentationFormat,
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
constants: {
|
|
281
|
+
shadowDepthTextureSize: this.shadowDepthTextureSize,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
depthStencil: {
|
|
285
|
+
depthWriteEnabled: true,
|
|
286
|
+
depthCompare: 'less',
|
|
287
|
+
format: 'depth24plus-stencil8',
|
|
288
|
+
},
|
|
289
|
+
primitive,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const depthTexture = this.device.createTexture({
|
|
293
|
+
size: [canvas.width, canvas.height],
|
|
294
|
+
format: 'depth24plus-stencil8',
|
|
295
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
this.renderPassDescriptor = {
|
|
299
|
+
colorAttachments: [
|
|
300
|
+
{
|
|
301
|
+
// view is acquired and set in render loop.
|
|
302
|
+
view: undefined,
|
|
303
|
+
clearValue: {r: 0.5, g: 0.5, b: 0.5, a: 1.0},
|
|
304
|
+
loadOp: 'load',
|
|
305
|
+
storeOp: 'store',
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
depthStencilAttachment: {
|
|
309
|
+
view: depthTexture.createView(),
|
|
310
|
+
depthClearValue: 1.0,
|
|
311
|
+
depthLoadOp: 'clear',
|
|
312
|
+
depthStoreOp: 'store',
|
|
313
|
+
stencilClearValue: 0,
|
|
314
|
+
stencilLoadOp: 'clear',
|
|
315
|
+
stencilStoreOp: 'store',
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
this.modelUniformBuffer = this.device.createBuffer({
|
|
320
|
+
size: 4 * 16, // 4x4 matrix
|
|
321
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
this.sceneUniformBuffer = this.device.createBuffer({
|
|
325
|
+
// Two 4x4 viewProj matrices,
|
|
326
|
+
// one for the camera and one for the light.
|
|
327
|
+
// Then a vec3 for the light position.
|
|
328
|
+
// Rounded to the nearest multiple of 16.
|
|
329
|
+
size: 2 * 4 * 16 + 4 * 4,
|
|
330
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
this.sceneBindGroupForShadow = this.device.createBindGroup({
|
|
334
|
+
layout: this.uniformBufferBindGroupLayout,
|
|
335
|
+
entries: [
|
|
336
|
+
{
|
|
337
|
+
binding: 0,
|
|
338
|
+
resource: {
|
|
339
|
+
buffer: this.sceneUniformBuffer,
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
this.sceneBindGroupForRender = this.device.createBindGroup({
|
|
346
|
+
layout: this.bglForRender,
|
|
347
|
+
entries: [
|
|
348
|
+
{
|
|
349
|
+
binding: 0,
|
|
350
|
+
resource: {
|
|
351
|
+
buffer: this.sceneUniformBuffer,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
binding: 1,
|
|
356
|
+
resource: this.shadowDepthTextureView,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
binding: 2,
|
|
360
|
+
resource: this.device.createSampler({
|
|
361
|
+
compare: 'less',
|
|
362
|
+
}),
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
binding: 3,
|
|
366
|
+
resource: this.texture0.createView(),
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
binding: 4,
|
|
370
|
+
resource: this.sampler,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
this.modelBindGroup = this.device.createBindGroup({
|
|
376
|
+
layout: this.uniformBufferBindGroupLayout,
|
|
377
|
+
entries: [
|
|
378
|
+
{
|
|
379
|
+
binding: 0,
|
|
380
|
+
resource: {
|
|
381
|
+
buffer: this.modelUniformBuffer,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// Rotates the camera around the origin based on time.
|
|
388
|
+
this.getTransformationMatrix = (pos) => {
|
|
389
|
+
const now = Date.now();
|
|
390
|
+
const deltaTime = (now - this.lastFrameMS) / this.mainCameraParams.responseCoef;
|
|
391
|
+
this.lastFrameMS = now;
|
|
392
|
+
// const this.viewMatrix = mat4.identity()
|
|
393
|
+
const camera = this.cameras[this.mainCameraParams.type];
|
|
394
|
+
this.viewMatrix = camera.update(deltaTime, this.inputHandler());
|
|
395
|
+
mat4.translate(this.viewMatrix, vec3.fromValues(pos.x, pos.y, pos.z), this.viewMatrix);
|
|
396
|
+
mat4.rotate(
|
|
397
|
+
this.viewMatrix,
|
|
398
|
+
vec3.fromValues(this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z),
|
|
399
|
+
degToRad(this.rotation.angle), this.viewMatrix)
|
|
400
|
+
// console.info('this: ', this)
|
|
401
|
+
mat4.rotateX(this.viewMatrix, Math.PI * this.rotation.getRotX(), this.viewMatrix);
|
|
402
|
+
mat4.rotateY(this.viewMatrix, Math.PI * this.rotation.getRotY(), this.viewMatrix);
|
|
403
|
+
mat4.rotateZ(this.viewMatrix, Math.PI * this.rotation.getRotZ(), this.viewMatrix);
|
|
404
|
+
// console.info('angle: ', this.rotation.angle, ' axis ' , this.rotation.axis.x, ' , ', this.rotation.axis.y, ' , ', this.rotation.axis.z)
|
|
405
|
+
mat4.multiply(this.projectionMatrix, this.viewMatrix, this.modelViewProjectionMatrix);
|
|
406
|
+
return this.modelViewProjectionMatrix;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
this.upVector = vec3.fromValues(0, 1, 0);
|
|
410
|
+
this.origin = vec3.fromValues(0, 0, 0);
|
|
411
|
+
|
|
412
|
+
this.lightPosition = vec3.fromValues(0, 0, 0);
|
|
413
|
+
this.lightViewMatrix = mat4.lookAt(this.lightPosition, this.origin, this.upVector);
|
|
414
|
+
const lightProjectionMatrix = mat4.create();
|
|
415
|
+
|
|
416
|
+
var myLMargin = 100;
|
|
417
|
+
{
|
|
418
|
+
const left = -myLMargin;
|
|
419
|
+
const right = myLMargin;
|
|
420
|
+
const bottom = -myLMargin;
|
|
421
|
+
const top = myLMargin;
|
|
422
|
+
const near = -200;
|
|
423
|
+
const far = 300;
|
|
424
|
+
mat4.ortho(left, right, bottom, top, near, far, lightProjectionMatrix);
|
|
425
|
+
// test
|
|
426
|
+
// mat4.ortho(right, left, top, bottom, near, far, lightProjectionMatrix);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
this.lightViewProjMatrix = mat4.multiply(
|
|
430
|
+
lightProjectionMatrix,
|
|
431
|
+
this.lightViewMatrix
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
// looks like affect on transformations for now const 0
|
|
435
|
+
const modelMatrix = mat4.translation([0, 0, 0]);
|
|
436
|
+
// The camera/light aren't moving, so write them into buffers now.
|
|
437
|
+
{
|
|
438
|
+
const lightMatrixData = this.lightViewProjMatrix; // as Float32Array;
|
|
439
|
+
this.device.queue.writeBuffer(
|
|
440
|
+
this.sceneUniformBuffer,
|
|
441
|
+
0,
|
|
442
|
+
lightMatrixData.buffer,
|
|
443
|
+
lightMatrixData.byteOffset,
|
|
444
|
+
lightMatrixData.byteLength
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
const lightData = this.lightPosition;
|
|
448
|
+
this.device.queue.writeBuffer(
|
|
449
|
+
this.sceneUniformBuffer,
|
|
450
|
+
128,
|
|
451
|
+
lightData.buffer,
|
|
452
|
+
lightData.byteOffset,
|
|
453
|
+
lightData.byteLength
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const modelData = modelMatrix;
|
|
457
|
+
this.device.queue.writeBuffer(
|
|
458
|
+
this.modelUniformBuffer,
|
|
459
|
+
0,
|
|
460
|
+
modelData.buffer,
|
|
461
|
+
modelData.byteOffset,
|
|
462
|
+
modelData.byteLength
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
this.shadowPassDescriptor = {
|
|
467
|
+
colorAttachments: [],
|
|
468
|
+
depthStencilAttachment: {
|
|
469
|
+
view: this.shadowDepthTextureView,
|
|
470
|
+
depthClearValue: 1.0,
|
|
471
|
+
depthLoadOp: 'clear',
|
|
472
|
+
depthStoreOp: 'store',
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
this.done = true;
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
updateLightsTest = (position) => {
|
|
481
|
+
console.log('Update light position.', position)
|
|
482
|
+
this.lightPosition = vec3.fromValues(position[0], position[1], position[2]);
|
|
483
|
+
this.lightViewMatrix = mat4.lookAt(this.lightPosition, this.origin, this.upVector);
|
|
484
|
+
|
|
485
|
+
const lightProjectionMatrix = mat4.create();
|
|
486
|
+
{
|
|
487
|
+
const left = -80;
|
|
488
|
+
const right = 80;
|
|
489
|
+
const bottom = -80;
|
|
490
|
+
const top = 80;
|
|
491
|
+
const near = -200;
|
|
492
|
+
const far = 300;
|
|
493
|
+
mat4.ortho(left, right, bottom, top, near, far, lightProjectionMatrix);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
this.lightViewProjMatrix = mat4.multiply(
|
|
497
|
+
lightProjectionMatrix,
|
|
498
|
+
this.lightViewMatrix
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
// looks like affect on transformations for now const 0
|
|
502
|
+
const modelMatrix = mat4.translation([0, 0, 0]);
|
|
503
|
+
// The camera/light aren't moving, so write them into buffers now.
|
|
504
|
+
{
|
|
505
|
+
const lightMatrixData = this.lightViewProjMatrix; // as Float32Array;
|
|
506
|
+
this.device.queue.writeBuffer(
|
|
507
|
+
this.sceneUniformBuffer,
|
|
508
|
+
0, // 0 ori
|
|
509
|
+
lightMatrixData.buffer,
|
|
510
|
+
lightMatrixData.byteOffset,
|
|
511
|
+
lightMatrixData.byteLength
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
const lightData = this.lightPosition;
|
|
515
|
+
this.device.queue.writeBuffer(
|
|
516
|
+
this.sceneUniformBuffer,
|
|
517
|
+
256,
|
|
518
|
+
lightData.buffer,
|
|
519
|
+
lightData.byteOffset,
|
|
520
|
+
lightData.byteLength
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
const modelData = modelMatrix;
|
|
524
|
+
this.device.queue.writeBuffer(
|
|
525
|
+
this.modelUniformBuffer,
|
|
526
|
+
0,
|
|
527
|
+
modelData.buffer,
|
|
528
|
+
modelData.byteOffset,
|
|
529
|
+
modelData.byteLength
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
this.shadowPassDescriptor = {
|
|
534
|
+
colorAttachments: [],
|
|
535
|
+
depthStencilAttachment: {
|
|
536
|
+
view: this.shadowDepthTextureView,
|
|
537
|
+
depthClearValue: 1.0, // ori 1.0
|
|
538
|
+
depthLoadOp: 'clear',
|
|
539
|
+
depthStoreOp: 'store',
|
|
540
|
+
},
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
///////////////////////
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
async loadTex0(texturesPaths, device) {
|
|
547
|
+
|
|
548
|
+
this.sampler = device.createSampler({
|
|
549
|
+
magFilter: 'linear',
|
|
550
|
+
minFilter: 'linear',
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
return new Promise(async (resolve) => {
|
|
554
|
+
const response = await fetch(texturesPaths[0]);
|
|
555
|
+
const imageBitmap = await createImageBitmap(await response.blob());
|
|
556
|
+
this.texture0 = device.createTexture({
|
|
557
|
+
size: [imageBitmap.width, imageBitmap.height, 1],
|
|
558
|
+
format: 'rgba8unorm',
|
|
559
|
+
usage:
|
|
560
|
+
GPUTextureUsage.TEXTURE_BINDING |
|
|
561
|
+
GPUTextureUsage.COPY_DST |
|
|
562
|
+
GPUTextureUsage.RENDER_ATTACHMENT,
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
device.queue.copyExternalImageToTexture(
|
|
566
|
+
{source: imageBitmap},
|
|
567
|
+
{texture: this.texture0},
|
|
568
|
+
[imageBitmap.width, imageBitmap.height]
|
|
569
|
+
);
|
|
570
|
+
resolve()
|
|
571
|
+
})
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
draw = (commandEncoder) => {
|
|
575
|
+
if(this.done == false) return;
|
|
576
|
+
// console.log('test draw for meshObj !')
|
|
577
|
+
const transformationMatrix = this.getTransformationMatrix(this.position);
|
|
578
|
+
this.device.queue.writeBuffer(
|
|
579
|
+
this.sceneUniformBuffer,
|
|
580
|
+
64,
|
|
581
|
+
transformationMatrix.buffer,
|
|
582
|
+
transformationMatrix.byteOffset,
|
|
583
|
+
transformationMatrix.byteLength
|
|
584
|
+
);
|
|
585
|
+
this.renderPassDescriptor.colorAttachments[0].view = this.context
|
|
586
|
+
.getCurrentTexture()
|
|
587
|
+
.createView();
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
drawElements = (renderPass) => {
|
|
591
|
+
renderPass.setBindGroup(0, this.sceneBindGroupForRender);
|
|
592
|
+
renderPass.setBindGroup(1, this.modelBindGroup);
|
|
593
|
+
renderPass.setVertexBuffer(0, this.vertexBuffer);
|
|
594
|
+
renderPass.setVertexBuffer(1, this.vertexNormalsBuffer);
|
|
595
|
+
renderPass.setVertexBuffer(2, this.vertexTexCoordsBuffer);
|
|
596
|
+
renderPass.setIndexBuffer(this.indexBuffer, 'uint16');
|
|
597
|
+
renderPass.drawIndexed(this.indexCount);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
drawShadows = (shadowPass) => {
|
|
601
|
+
shadowPass.setBindGroup(0, this.sceneBindGroupForShadow);
|
|
602
|
+
shadowPass.setBindGroup(1, this.modelBindGroup);
|
|
603
|
+
shadowPass.setVertexBuffer(0, this.vertexBuffer);
|
|
604
|
+
shadowPass.setVertexBuffer(1, this.vertexNormalsBuffer);
|
|
605
|
+
shadowPass.setVertexBuffer(2, this.vertexTexCoordsBuffer);
|
|
606
|
+
shadowPass.setIndexBuffer(this.indexBuffer, 'uint16');
|
|
607
|
+
shadowPass.drawIndexed(this.indexCount);
|
|
608
|
+
}
|
|
605
609
|
}
|
|
@@ -196,8 +196,31 @@ export default class MatrixAmmo {
|
|
|
196
196
|
return b;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
deactivatePhysics(body) {
|
|
200
|
+
const CF_KINEMATIC_OBJECT = 2;
|
|
201
|
+
const DISABLE_DEACTIVATION = 4;
|
|
202
|
+
// 1. Remove from world
|
|
203
|
+
this.dynamicsWorld.removeRigidBody(body);
|
|
204
|
+
// 2. Set body to kinematic
|
|
205
|
+
const flags = body.getCollisionFlags();
|
|
206
|
+
body.setCollisionFlags(flags | CF_KINEMATIC_OBJECT);
|
|
207
|
+
body.setActivationState(DISABLE_DEACTIVATION); // no auto-wakeup
|
|
208
|
+
// 3. Clear motion
|
|
209
|
+
const zero = new Ammo.btVector3(0, 0, 0);
|
|
210
|
+
body.setLinearVelocity(zero);
|
|
211
|
+
body.setAngularVelocity(zero);
|
|
212
|
+
// 4. Reset transform to current position (optional — preserves pose)
|
|
213
|
+
const currentTransform = body.getWorldTransform();
|
|
214
|
+
body.setWorldTransform(currentTransform);
|
|
215
|
+
body.getMotionState().setWorldTransform(currentTransform);
|
|
216
|
+
// 5. Add back to physics world
|
|
217
|
+
this.matrixAmmo.dynamicsWorld.addRigidBody(body);
|
|
218
|
+
// 6. Mark it manually (logic flag)
|
|
219
|
+
body.isKinematic = true;
|
|
220
|
+
}
|
|
221
|
+
|
|
199
222
|
detectCollision() {
|
|
200
|
-
console.log('override this')
|
|
223
|
+
// console.log('override this')
|
|
201
224
|
return;
|
|
202
225
|
|
|
203
226
|
this.lastRoll = '';
|
package/src/world.js
CHANGED
|
@@ -282,8 +282,6 @@ export default class MatrixEngineWGPU {
|
|
|
282
282
|
if(typeof o.physics.name === 'undefined') {o.physics.name = o.name;}
|
|
283
283
|
if(typeof o.physics.scale === 'undefined') {o.physics.scale = o.scale;}
|
|
284
284
|
if(typeof o.physics.rotation === 'undefined') {o.physics.rotation = o.rotation;}
|
|
285
|
-
|
|
286
|
-
// send same pos
|
|
287
285
|
o.physics.position = o.position;
|
|
288
286
|
// console.log('Mesh procedure', o)
|
|
289
287
|
let myMesh1 = new MEMeshObj(this.canvas, this.device, this.context, o)
|