pacem 0.51.1 → 0.51.2-atlantis
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/dist/css/pacem-dark-content.min.css +1 -1
- package/dist/css/pacem-dark-shell.min.css +1 -1
- package/dist/css/pacem-dark.min.css +1 -1
- package/dist/css/pacem-light-content.min.css +1 -1
- package/dist/css/pacem-light-shell.min.css +1 -1
- package/dist/css/pacem-light.min.css +1 -1
- package/dist/css/pacem-phousys-content.min.css +1 -1
- package/dist/css/pacem-phousys-shell.min.css +1 -1
- package/dist/css/pacem-phousys.min.css +1 -1
- package/dist/js/azure-maps.d.ts +1 -1
- package/dist/js/pacem-2d.d.ts +1 -1
- package/dist/js/pacem-2d.js +1 -1
- package/dist/js/pacem-2d.min.js +1 -1
- package/dist/js/pacem-3d.d.ts +5 -3
- package/dist/js/pacem-3d.js +109 -53
- package/dist/js/pacem-3d.min.js +2 -2
- package/dist/js/pacem-charts.d.ts +1 -1
- package/dist/js/pacem-charts.js +1 -1
- package/dist/js/pacem-charts.min.js +1 -1
- package/dist/js/pacem-cms.d.ts +1 -1
- package/dist/js/pacem-cms.js +1 -1
- package/dist/js/pacem-cms.min.js +1 -1
- package/dist/js/pacem-core.d.ts +1 -1
- package/dist/js/pacem-core.js +1 -1
- package/dist/js/pacem-core.min.js +1 -1
- package/dist/js/pacem-foundation.d.ts +1 -1
- package/dist/js/pacem-foundation.js +1 -1
- package/dist/js/pacem-foundation.min.js +1 -1
- package/dist/js/pacem-fx.d.ts +1 -1
- package/dist/js/pacem-fx.js +1 -1
- package/dist/js/pacem-fx.min.js +1 -1
- package/dist/js/pacem-logging.d.ts +1 -1
- package/dist/js/pacem-logging.js +1 -1
- package/dist/js/pacem-logging.min.js +1 -1
- package/dist/js/pacem-maps.d.ts +1 -1
- package/dist/js/pacem-maps.js +1 -1
- package/dist/js/pacem-maps.min.js +1 -1
- package/dist/js/pacem-media.d.ts +1 -1
- package/dist/js/pacem-media.js +1 -1
- package/dist/js/pacem-media.min.js +1 -1
- package/dist/js/pacem-networking.d.ts +1 -1
- package/dist/js/pacem-networking.js +1 -1
- package/dist/js/pacem-networking.min.js +1 -1
- package/dist/js/pacem-numerical.d.ts +1 -1
- package/dist/js/pacem-numerical.js +1 -1
- package/dist/js/pacem-numerical.min.js +1 -1
- package/dist/js/pacem-plus.d.ts +1 -1
- package/dist/js/pacem-plus.js +1 -1
- package/dist/js/pacem-plus.min.js +1 -1
- package/dist/js/pacem-scaffolding.d.ts +1 -1
- package/dist/js/pacem-scaffolding.js +1 -1
- package/dist/js/pacem-scaffolding.min.js +1 -1
- package/dist/js/pacem-ui.d.ts +1 -1
- package/dist/js/pacem-ui.js +1 -1
- package/dist/js/pacem-ui.min.js +1 -1
- package/dist/js/swagger-types.d.ts +1 -1
- package/package.json +1 -1
package/dist/js/azure-maps.d.ts
CHANGED
package/dist/js/pacem-2d.d.ts
CHANGED
package/dist/js/pacem-2d.js
CHANGED
package/dist/js/pacem-2d.min.js
CHANGED
package/dist/js/pacem-3d.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pacem v0.51.
|
|
2
|
+
* pacem v0.51.2-atlantis (https://js.pacem.it)
|
|
3
3
|
* Copyright 2025 Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -536,7 +536,7 @@ declare namespace Pacem.Drawing3D.WebGPU {
|
|
|
536
536
|
readonly format: GPUTextureFormat;
|
|
537
537
|
}
|
|
538
538
|
type RenderPassEncoderBindDelegate = (pass: GPURenderPassEncoder, ...buffers: RenderableBuffer[]) => void;
|
|
539
|
-
type RenderableBufferKey = 'u32id' | 'cameraViewTransform' | 'cameraViewProjectionTransform' | 'cameraInverseViewProjectionTransform' | 'objectWorldTransform' | 'geometryPositions' | 'light' | 'geometryNormals' | 'geometryTexCoords' | 'vertexColors';
|
|
539
|
+
type RenderableBufferKey = 'u32id' | 'cameraViewTransform' | 'cameraViewProjectionTransform' | 'cameraInverseViewProjectionTransform' | 'objectWorldTransform' | 'geometryPositions' | 'light' | 'geometryNormals' | 'geometryTexCoords' | 'vertexColors' | 'geometry';
|
|
540
540
|
type MaterialKey = 'texture' | 'sampler' | 'normalTexture' | '';
|
|
541
541
|
type Texture = {
|
|
542
542
|
texture?: GPUTexture;
|
|
@@ -649,7 +649,8 @@ declare namespace Pacem.Drawing3D.WebGPU {
|
|
|
649
649
|
static createIndexed(device: GPUDevice, data: Uint16Array, label?: string): GPUBuffer;
|
|
650
650
|
}
|
|
651
651
|
class BufferLayouts {
|
|
652
|
-
static createVertex(shaderLocation
|
|
652
|
+
static createVertex(shaderLocation: number, size?: number): GPUVertexBufferLayout;
|
|
653
|
+
static createVertex(shaderLocationStart: number, ...sizes: number[]): GPUVertexBufferLayout;
|
|
653
654
|
}
|
|
654
655
|
}
|
|
655
656
|
declare namespace Pacem.Drawing3D.WebGPU {
|
|
@@ -761,6 +762,7 @@ declare namespace Pacem.Drawing3D.WebGPU {
|
|
|
761
762
|
type PipelineOptions = {
|
|
762
763
|
primitive: GPUPrimitiveState;
|
|
763
764
|
multisample: boolean;
|
|
765
|
+
packedVertices: boolean;
|
|
764
766
|
};
|
|
765
767
|
class RenderPipeline {
|
|
766
768
|
private static _memoizer;
|
package/dist/js/pacem-3d.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pacem v0.51.
|
|
2
|
+
* pacem v0.51.2-atlantis (https://js.pacem.it)
|
|
3
3
|
* Copyright 2025 Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -279,7 +279,7 @@ var Pacem;
|
|
|
279
279
|
}
|
|
280
280
|
Drawing3D.isStage = isStage;
|
|
281
281
|
function isRenderable(object) {
|
|
282
|
-
return
|
|
282
|
+
return isStage(object?.stage);
|
|
283
283
|
}
|
|
284
284
|
Drawing3D.isRenderable = isRenderable;
|
|
285
285
|
function isUi3DObject(object) {
|
|
@@ -287,7 +287,7 @@ var Pacem;
|
|
|
287
287
|
}
|
|
288
288
|
Drawing3D.isUi3DObject = isUi3DObject;
|
|
289
289
|
function isCamera(object) {
|
|
290
|
-
return
|
|
290
|
+
return 'type' in object && 'up' in object && 'lookAt' in object && isRenderable(object);
|
|
291
291
|
}
|
|
292
292
|
Drawing3D.isCamera = isCamera;
|
|
293
293
|
function isPerspectiveCamera(object) {
|
|
@@ -299,11 +299,11 @@ var Pacem;
|
|
|
299
299
|
}
|
|
300
300
|
Drawing3D.isOrthographicCamera = isOrthographicCamera;
|
|
301
301
|
function isLight(object) {
|
|
302
|
-
return
|
|
302
|
+
return 'type' in object && (object.type === 'omni' || object.type === 'direction' || object.type == 'spot') && isRenderable(object);
|
|
303
303
|
}
|
|
304
304
|
Drawing3D.isLight = isLight;
|
|
305
305
|
function isMesh(object) {
|
|
306
|
-
return
|
|
306
|
+
return 'geometry' in object && isUi3DObject(object);
|
|
307
307
|
}
|
|
308
308
|
Drawing3D.isMesh = isMesh;
|
|
309
309
|
function isGeometry(object) {
|
|
@@ -311,14 +311,13 @@ var Pacem;
|
|
|
311
311
|
}
|
|
312
312
|
Drawing3D.isGeometry = isGeometry;
|
|
313
313
|
function isMeshGeometry(object) {
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|| 'textureCoordinates' in object && Pacem.Utils.isArray(object.textureCoordinates));
|
|
314
|
+
return ('triangleIndices' in object && Pacem.Utils.isArray(object.triangleIndices)
|
|
315
|
+
|| 'normals' in object && Pacem.Utils.isArray(object.normals)
|
|
316
|
+
|| 'textureCoordinates' in object && Pacem.Utils.isArray(object.textureCoordinates)) && isGeometry(object);
|
|
318
317
|
}
|
|
319
318
|
Drawing3D.isMeshGeometry = isMeshGeometry;
|
|
320
319
|
function isGroup(object) {
|
|
321
|
-
return
|
|
320
|
+
return 'childRenderables' in object && !Pacem.Utils.isNullOrEmpty(object['childRenderables']) && isUi3DObject(object);
|
|
322
321
|
}
|
|
323
322
|
Drawing3D.isGroup = isGroup;
|
|
324
323
|
/**
|
|
@@ -1971,16 +1970,21 @@ var Pacem;
|
|
|
1971
1970
|
}
|
|
1972
1971
|
WebGPU.Buffers = Buffers;
|
|
1973
1972
|
class BufferLayouts {
|
|
1974
|
-
static createVertex(
|
|
1973
|
+
static createVertex(shaderLocationStart = 0, size = 3, ...sizes) {
|
|
1974
|
+
const attributes = [];
|
|
1975
|
+
let fullSize = 0, index = 0;
|
|
1976
|
+
for (let sz of [size].concat(sizes)) {
|
|
1977
|
+
attributes.push({
|
|
1978
|
+
shaderLocation: shaderLocationStart + index,
|
|
1979
|
+
offset: fullSize * Float32Array.BYTES_PER_ELEMENT,
|
|
1980
|
+
format: `float32x${sz}`,
|
|
1981
|
+
});
|
|
1982
|
+
fullSize += sz;
|
|
1983
|
+
index++;
|
|
1984
|
+
}
|
|
1975
1985
|
return {
|
|
1976
|
-
arrayStride:
|
|
1977
|
-
attributes
|
|
1978
|
-
{
|
|
1979
|
-
shaderLocation,
|
|
1980
|
-
offset: 0,
|
|
1981
|
-
format: `float32x${size}`,
|
|
1982
|
-
}
|
|
1983
|
-
],
|
|
1986
|
+
arrayStride: fullSize /* x, y, z */ * Float32Array.BYTES_PER_ELEMENT,
|
|
1987
|
+
attributes,
|
|
1984
1988
|
stepMode: 'vertex'
|
|
1985
1989
|
};
|
|
1986
1990
|
}
|
|
@@ -2306,6 +2310,7 @@ var Pacem;
|
|
|
2306
2310
|
const labelPrefix = WebGPU.LABEL_PREFIX;
|
|
2307
2311
|
const DefaultPipelineOptions = {
|
|
2308
2312
|
multisample: true,
|
|
2313
|
+
packedVertices: true,
|
|
2309
2314
|
primitive: {
|
|
2310
2315
|
topology: 'triangle-list',
|
|
2311
2316
|
frontFace: 'ccw',
|
|
@@ -2497,8 +2502,9 @@ var Pacem;
|
|
|
2497
2502
|
const meshPipeline = new MeshRenderPipelineClass(ctx, mesh, camera, ...lights);
|
|
2498
2503
|
// cache peek for sudden return
|
|
2499
2504
|
const key = meshPipeline.key;
|
|
2500
|
-
|
|
2501
|
-
|
|
2505
|
+
const found = cache.get(key);
|
|
2506
|
+
if (found) {
|
|
2507
|
+
return found;
|
|
2502
2508
|
}
|
|
2503
2509
|
// no cache -> build it
|
|
2504
2510
|
meshPipeline.build(pipelineOptions);
|
|
@@ -2522,7 +2528,8 @@ var Pacem;
|
|
|
2522
2528
|
// #region fields and utils
|
|
2523
2529
|
this._ensureU32idBindGroup = (item, buffer, refresh) => {
|
|
2524
2530
|
let set = this._idBindGroups;
|
|
2525
|
-
|
|
2531
|
+
let retval = set.get(item);
|
|
2532
|
+
if (refresh || Pacem.Utils.isNull(retval)) {
|
|
2526
2533
|
const { device } = this._context;
|
|
2527
2534
|
const layout = this._pickBindGroupLayout;
|
|
2528
2535
|
if (layout.label !== (labelPrefix + 'mesh-colorpick-bind-group-layout')) {
|
|
@@ -2538,13 +2545,14 @@ var Pacem;
|
|
|
2538
2545
|
}
|
|
2539
2546
|
}]
|
|
2540
2547
|
});
|
|
2541
|
-
set.set(item, actual);
|
|
2548
|
+
set.set(item, retval = actual);
|
|
2542
2549
|
}
|
|
2543
|
-
return
|
|
2550
|
+
return retval;
|
|
2544
2551
|
};
|
|
2545
2552
|
this._ensureMaterialBindGroup = (item, buffer, texBmp, refresh, layoutIndex = WebGPU.MATERIAL_GROUP_INDEX) => {
|
|
2546
2553
|
let set = this._materialBindGroups;
|
|
2547
|
-
|
|
2554
|
+
let retval = set.get(item);
|
|
2555
|
+
if (refresh || Pacem.Utils.isNull(retval)) {
|
|
2548
2556
|
const { device } = this._context;
|
|
2549
2557
|
const layout = this._bindGroupLayouts[layoutIndex];
|
|
2550
2558
|
if (layout.label !== (labelPrefix + 'material-bind-group-layout')) {
|
|
@@ -2576,13 +2584,14 @@ var Pacem;
|
|
|
2576
2584
|
layout,
|
|
2577
2585
|
entries
|
|
2578
2586
|
});
|
|
2579
|
-
set.set(item, [actual, texture]);
|
|
2587
|
+
set.set(item, retval = [actual, texture]);
|
|
2580
2588
|
}
|
|
2581
|
-
return
|
|
2589
|
+
return retval;
|
|
2582
2590
|
};
|
|
2583
2591
|
this._ensureWorldTransformBindGroup = (item, buffer, refresh, layoutIndex = WebGPU.UNIFORM_GROUP_INDEX_WORLDTRANSFORM) => {
|
|
2584
2592
|
let set = this._meshBindGroups;
|
|
2585
|
-
|
|
2593
|
+
let retval = set.get(item);
|
|
2594
|
+
if (refresh || Pacem.Utils.isNull(retval)) {
|
|
2586
2595
|
const { device } = this._context;
|
|
2587
2596
|
const layout = this._bindGroupLayouts[layoutIndex];
|
|
2588
2597
|
if (layout.label !== (labelPrefix + 'mesh-transforms-bind-group-layout')) {
|
|
@@ -2597,13 +2606,14 @@ var Pacem;
|
|
|
2597
2606
|
}
|
|
2598
2607
|
}]
|
|
2599
2608
|
});
|
|
2600
|
-
set.set(item, actual);
|
|
2609
|
+
set.set(item, retval = actual);
|
|
2601
2610
|
}
|
|
2602
|
-
return
|
|
2611
|
+
return retval;
|
|
2603
2612
|
};
|
|
2604
2613
|
this._ensureCameraProjectionBindGroup = (item, viewBuffer, viewProjectionBuffer, refresh, layoutIndex = WebGPU.UNIFORM_GROUP_INDEX_VIEWTRANSFORM) => {
|
|
2605
2614
|
let set = this._cameraProjectionBindGroups;
|
|
2606
|
-
|
|
2615
|
+
let retval = set.get(item);
|
|
2616
|
+
if (refresh || Pacem.Utils.isNull(retval)) {
|
|
2607
2617
|
const { device } = this._context;
|
|
2608
2618
|
const layout = this._bindGroupLayouts[layoutIndex];
|
|
2609
2619
|
const actual = device.createBindGroup({
|
|
@@ -2620,14 +2630,15 @@ var Pacem;
|
|
|
2620
2630
|
}
|
|
2621
2631
|
}]
|
|
2622
2632
|
});
|
|
2623
|
-
set.set(item, actual);
|
|
2633
|
+
set.set(item, retval = actual);
|
|
2624
2634
|
}
|
|
2625
|
-
return
|
|
2635
|
+
return retval;
|
|
2626
2636
|
};
|
|
2627
2637
|
this._ensureLightingBindGroup = (lights, refresh, layoutIndex = WebGPU.UNIFORM_GROUP_INDEX_LIGHTING) => {
|
|
2628
2638
|
let set = this._lightingBindGroups;
|
|
2629
2639
|
const key = lights.map(l => l.id).join(':');
|
|
2630
|
-
|
|
2640
|
+
let retval = set.get(key);
|
|
2641
|
+
if (refresh || Pacem.Utils.isNull(retval)) {
|
|
2631
2642
|
const { device } = this._context;
|
|
2632
2643
|
const layout = this._bindGroupLayouts[layoutIndex];
|
|
2633
2644
|
const entries = lights.map((light, index) => {
|
|
@@ -2641,9 +2652,9 @@ var Pacem;
|
|
|
2641
2652
|
layout,
|
|
2642
2653
|
entries
|
|
2643
2654
|
});
|
|
2644
|
-
set.set(key, actual);
|
|
2655
|
+
set.set(key, retval = actual);
|
|
2645
2656
|
}
|
|
2646
|
-
return
|
|
2657
|
+
return retval;
|
|
2647
2658
|
};
|
|
2648
2659
|
this._bindGroupLayouts = [];
|
|
2649
2660
|
this._meshBindGroups = new WeakMap();
|
|
@@ -2684,16 +2695,23 @@ var Pacem;
|
|
|
2684
2695
|
lightBuffers.push(buffer);
|
|
2685
2696
|
}
|
|
2686
2697
|
}
|
|
2687
|
-
//
|
|
2688
|
-
pass
|
|
2698
|
+
// same pass
|
|
2699
|
+
const samePass = pass === this.#previousPass;
|
|
2700
|
+
if (!samePass) {
|
|
2701
|
+
this.#previousPass = pass;
|
|
2702
|
+
// set
|
|
2703
|
+
pass.setPipeline(this._pipeline);
|
|
2704
|
+
}
|
|
2689
2705
|
try {
|
|
2690
2706
|
// bind
|
|
2691
2707
|
this._bindVertex(pass, meshBuffer);
|
|
2692
2708
|
this._bindWorldTransform(pass, meshBuffer);
|
|
2693
|
-
this._bindCameraProjection(pass, cameraBuffer);
|
|
2694
2709
|
this._bindMaterial(pass, meshBuffer);
|
|
2695
2710
|
this._bindTextures(pass, meshBuffer);
|
|
2696
|
-
|
|
2711
|
+
if (!samePass) {
|
|
2712
|
+
this._bindCameraProjection(pass, cameraBuffer);
|
|
2713
|
+
this._bindLighting(pass, ...lightBuffers);
|
|
2714
|
+
}
|
|
2697
2715
|
// draw
|
|
2698
2716
|
const mesh = meshBuffer.item, geometry = mesh.geometry;
|
|
2699
2717
|
pass.draw(geometry.triangleIndices?.length || geometry.positions.length);
|
|
@@ -2749,14 +2767,19 @@ var Pacem;
|
|
|
2749
2767
|
// build vertex state
|
|
2750
2768
|
const vertex = {
|
|
2751
2769
|
module: device.createShaderModule({ code: wgsl.vertex }),
|
|
2752
|
-
buffers:
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2770
|
+
buffers: options.packedVertices ?
|
|
2771
|
+
[
|
|
2772
|
+
// packed
|
|
2773
|
+
WebGPU.BufferLayouts.createVertex(WebGPU.VERTEX_BUFFER_INDEX_MESH_POSITION, 3, 3, 2),
|
|
2774
|
+
]
|
|
2775
|
+
: [
|
|
2776
|
+
// position
|
|
2777
|
+
WebGPU.BufferLayouts.createVertex(WebGPU.VERTEX_BUFFER_INDEX_MESH_POSITION, 3),
|
|
2778
|
+
// normal
|
|
2779
|
+
WebGPU.BufferLayouts.createVertex(WebGPU.VERTEX_BUFFER_INDEX_MESH_NORMAL, 3),
|
|
2780
|
+
// uv
|
|
2781
|
+
WebGPU.BufferLayouts.createVertex(WebGPU.VERTEX_BUFFER_INDEX_MESH_UV, 2)
|
|
2782
|
+
]
|
|
2760
2783
|
};
|
|
2761
2784
|
// bind group layouts
|
|
2762
2785
|
const worldBindGroupLayout = device.createBindGroupLayout({
|
|
@@ -2919,7 +2942,7 @@ var Pacem;
|
|
|
2919
2942
|
this._materialBindGroups = new WeakMap();
|
|
2920
2943
|
this._lightingBindGroups.clear();
|
|
2921
2944
|
// vertex buffers
|
|
2922
|
-
|
|
2945
|
+
const bindVertexSplit = (pass, ...buffers) => {
|
|
2923
2946
|
const meshBuffer = buffers.at(0);
|
|
2924
2947
|
if (Pacem.Utils.isNull(meshBuffer)) {
|
|
2925
2948
|
throw new ReferenceError(`Null ${WebGPU.RenderableBuffer.name} bringing vertex buffers was provided.`);
|
|
@@ -2931,6 +2954,15 @@ var Pacem;
|
|
|
2931
2954
|
pass.setVertexBuffer(WebGPU.VERTEX_BUFFER_INDEX_MESH_NORMAL, normals);
|
|
2932
2955
|
pass.setVertexBuffer(WebGPU.VERTEX_BUFFER_INDEX_MESH_UV, uv);
|
|
2933
2956
|
};
|
|
2957
|
+
const bindVertexPacked = (pass, ...buffers) => {
|
|
2958
|
+
const meshBuffer = buffers.at(0);
|
|
2959
|
+
if (Pacem.Utils.isNull(meshBuffer)) {
|
|
2960
|
+
throw new ReferenceError(`Null ${WebGPU.RenderableBuffer.name} bringing vertex buffers was provided.`);
|
|
2961
|
+
}
|
|
2962
|
+
const { buffer } = meshBuffer.buffer(ctx, 'geometry');
|
|
2963
|
+
pass.setVertexBuffer(WebGPU.VERTEX_BUFFER_INDEX_MESH_POSITION, buffer);
|
|
2964
|
+
};
|
|
2965
|
+
this._bindVertex = options.packedVertices ? bindVertexPacked : bindVertexSplit;
|
|
2934
2966
|
// world transform
|
|
2935
2967
|
this._bindWorldTransform = (pass, ...buffers) => {
|
|
2936
2968
|
const meshBuffer = buffers.at(0);
|
|
@@ -2999,6 +3031,7 @@ var Pacem;
|
|
|
2999
3031
|
pass.setBindGroup(group, bindGroup);
|
|
3000
3032
|
};
|
|
3001
3033
|
}
|
|
3034
|
+
#previousPass;
|
|
3002
3035
|
}
|
|
3003
3036
|
})(WebGPU = Drawing3D.WebGPU || (Drawing3D.WebGPU = {}));
|
|
3004
3037
|
})(Drawing3D = Pacem.Drawing3D || (Pacem.Drawing3D = {}));
|
|
@@ -3432,7 +3465,7 @@ var Pacem;
|
|
|
3432
3465
|
// #endregion
|
|
3433
3466
|
// #region GEOMETRY
|
|
3434
3467
|
class GeometryBuffer {
|
|
3435
|
-
#freshness = { positions: true, normals: true, uv: true };
|
|
3468
|
+
#freshness = { positions: true, normals: true, uv: true, packed: true };
|
|
3436
3469
|
#geometry;
|
|
3437
3470
|
#geometryBuffers;
|
|
3438
3471
|
constructor(geometry) {
|
|
@@ -3471,6 +3504,11 @@ var Pacem;
|
|
|
3471
3504
|
const { uv } = geom, uvFresh = freshness.uv;
|
|
3472
3505
|
freshness.uv = false;
|
|
3473
3506
|
return Pacem.Utils.extend({ fresh: uvFresh }, uv);
|
|
3507
|
+
case 'geometry':
|
|
3508
|
+
// alltogether
|
|
3509
|
+
const { packed } = geom, geomFresh = freshness.packed;
|
|
3510
|
+
freshness.packed = false;
|
|
3511
|
+
return Pacem.Utils.extend({ fresh: geomFresh }, packed);
|
|
3474
3512
|
default:
|
|
3475
3513
|
throwBufferRequestError(key, GeometryBuffer);
|
|
3476
3514
|
}
|
|
@@ -3488,13 +3526,28 @@ var Pacem;
|
|
|
3488
3526
|
const flatPositions = hasTriangleIndices ?
|
|
3489
3527
|
meshGeometry.triangleIndices.map(index => meshGeometry.positions[index])
|
|
3490
3528
|
: meshGeometry.positions;
|
|
3491
|
-
const
|
|
3529
|
+
const length2 = flatPositions.length * 2, length3 = length2 + flatPositions.length;
|
|
3530
|
+
const positionsValue = new Float32Array(length3); //AdapterUtils.flattenVectorArray(flatPositions));
|
|
3531
|
+
const normalsValue = new Float32Array(length3); //AdapterUtils.flattenVectorArray(meshGeometry.normals));
|
|
3532
|
+
const uvValue = new Float32Array(length2); //AdapterUtils.flattenVectorArray(meshGeometry.textureCoordinates));
|
|
3533
|
+
const geomValue = new Float32Array(2 * length3 + length2);
|
|
3534
|
+
for (let j = 0; j < flatPositions.length; j++) {
|
|
3535
|
+
const offset2 = 2 * j;
|
|
3536
|
+
const offset3 = 3 * j;
|
|
3537
|
+
const { x, y, z } = flatPositions[j];
|
|
3538
|
+
const { x: nx, y: ny, z: nz } = meshGeometry.normals[j];
|
|
3539
|
+
const { x: u, y: v } = meshGeometry.textureCoordinates[j];
|
|
3540
|
+
positionsValue.set([x, y, z], offset3);
|
|
3541
|
+
normalsValue.set([nx, ny, nz], offset3);
|
|
3542
|
+
uvValue.set([u, v], offset2);
|
|
3543
|
+
geomValue.set([x, y, z, nx, ny, nz, u, v], offset3 * 2 + offset2);
|
|
3544
|
+
}
|
|
3492
3545
|
const positions = WebGPU.Buffers.create(device, positionsValue, WebGPU.LABEL_PREFIX + 'meshgeometry-' + key + '-positions-buffer');
|
|
3493
|
-
const normalsValue = new Float32Array(AdapterUtils.flattenVectorArray(meshGeometry.normals));
|
|
3494
3546
|
const normals = WebGPU.Buffers.create(device, normalsValue, WebGPU.LABEL_PREFIX + 'meshgeometry-' + key + '-normals-buffer');
|
|
3495
|
-
const uvValue = new Float32Array(AdapterUtils.flattenVectorArray(meshGeometry.textureCoordinates));
|
|
3496
3547
|
const uv = WebGPU.Buffers.create(device, uvValue, WebGPU.LABEL_PREFIX + 'meshgeometry-' + key + '-uvmap-buffer');
|
|
3548
|
+
const geom = WebGPU.Buffers.create(device, geomValue, WebGPU.LABEL_PREFIX + 'meshgeometry-' + key + '-buffer');
|
|
3497
3549
|
this.#geometryBuffers = {
|
|
3550
|
+
packed: { buffer: geom, value: geomValue },
|
|
3498
3551
|
positions: { buffer: positions, value: positionsValue },
|
|
3499
3552
|
normals: { buffer: normals, value: normalsValue },
|
|
3500
3553
|
uv: { buffer: uv, value: uvValue },
|
|
@@ -3507,8 +3560,10 @@ var Pacem;
|
|
|
3507
3560
|
positions: { buffer: positions, value: positionsValue },
|
|
3508
3561
|
normals: { buffer: null, value: null },
|
|
3509
3562
|
uv: { buffer: null, value: null },
|
|
3563
|
+
packed: { buffer: null, value: null }
|
|
3510
3564
|
};
|
|
3511
3565
|
}
|
|
3566
|
+
this.#freshness = { positions: true, normals: true, uv: true, packed: true };
|
|
3512
3567
|
}
|
|
3513
3568
|
destroy() {
|
|
3514
3569
|
this.destroyBuffers();
|
|
@@ -3639,6 +3694,7 @@ var Pacem;
|
|
|
3639
3694
|
case 'geometryPositions':
|
|
3640
3695
|
case 'geometryNormals':
|
|
3641
3696
|
case 'geometryTexCoords':
|
|
3697
|
+
case 'geometry':
|
|
3642
3698
|
return geom.buffer(context, key);
|
|
3643
3699
|
case 'vertexColors':
|
|
3644
3700
|
return mater.buffer(context, key);
|