@pacem/pacem 1.0.0-abel → 1.0.0-amaldi
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/browser/pacem-2d.js +3 -3
- package/dist/browser/pacem-2d.js.map +0 -5
- package/dist/browser/pacem-2d.min.js +3 -3
- package/dist/browser/pacem-2d.min.js.map +0 -5
- package/dist/browser/pacem-3d.js +341 -341
- package/dist/browser/pacem-3d.js.map +1 -6
- package/dist/browser/pacem-3d.min.js +3 -3
- package/dist/browser/pacem-3d.min.js.map +1 -6
- package/dist/browser/pacem-charts.js +3 -3
- package/dist/browser/pacem-charts.js.map +0 -5
- package/dist/browser/pacem-charts.min.js +3 -3
- package/dist/browser/pacem-charts.min.js.map +0 -5
- package/dist/browser/pacem-cms.js +107 -107
- package/dist/browser/pacem-cms.js.map +1 -6
- package/dist/browser/pacem-cms.min.js +3 -3
- package/dist/browser/pacem-cms.min.js.map +1 -6
- package/dist/browser/pacem-core.js +21 -7
- package/dist/browser/pacem-core.js.map +1 -6
- package/dist/browser/pacem-core.min.js +4 -4
- package/dist/browser/pacem-core.min.js.map +1 -6
- package/dist/browser/pacem-foundation.js +3 -3
- package/dist/browser/pacem-foundation.js.map +0 -5
- package/dist/browser/pacem-foundation.min.js +3 -3
- package/dist/browser/pacem-foundation.min.js.map +0 -5
- package/dist/browser/pacem-fx.js +19 -19
- package/dist/browser/pacem-fx.js.map +1 -6
- package/dist/browser/pacem-fx.min.js +3 -3
- package/dist/browser/pacem-fx.min.js.map +1 -6
- package/dist/browser/pacem-logging.js +3 -3
- package/dist/browser/pacem-logging.js.map +0 -5
- package/dist/browser/pacem-logging.min.js +3 -3
- package/dist/browser/pacem-logging.min.js.map +0 -5
- package/dist/browser/pacem-maps.js +3 -3
- package/dist/browser/pacem-maps.js.map +0 -5
- package/dist/browser/pacem-maps.min.js +3 -3
- package/dist/browser/pacem-maps.min.js.map +0 -5
- package/dist/browser/pacem-media.js +3 -3
- package/dist/browser/pacem-media.js.map +0 -5
- package/dist/browser/pacem-media.min.js +3 -3
- package/dist/browser/pacem-media.min.js.map +0 -5
- package/dist/browser/pacem-networking.js +3 -3
- package/dist/browser/pacem-networking.js.map +0 -5
- package/dist/browser/pacem-networking.min.js +3 -3
- package/dist/browser/pacem-networking.min.js.map +0 -5
- package/dist/browser/pacem-numerical.js +3 -3
- package/dist/browser/pacem-numerical.js.map +0 -5
- package/dist/browser/pacem-numerical.min.js +3 -3
- package/dist/browser/pacem-numerical.min.js.map +0 -5
- package/dist/browser/pacem-plus.js +77 -77
- package/dist/browser/pacem-plus.js.map +1 -6
- package/dist/browser/pacem-plus.min.js +3 -3
- package/dist/browser/pacem-plus.min.js.map +1 -6
- package/dist/browser/pacem-scaffolding.js +11 -8
- package/dist/browser/pacem-scaffolding.js.map +1 -6
- package/dist/browser/pacem-scaffolding.min.js +4 -4
- package/dist/browser/pacem-scaffolding.min.js.map +1 -6
- package/dist/browser/pacem-ui.js +37 -26
- package/dist/browser/pacem-ui.js.map +1 -6
- package/dist/browser/pacem-ui.min.js +4 -4
- package/dist/browser/pacem-ui.min.js.map +1 -6
- package/dist/bundle/pacem.min.mjs +40 -38
- package/dist/bundle/pacem.mjs +58 -32
- package/dist/bundle/pacem.mjs.map +2 -7
- package/dist/typings/index.d.ts +5 -3
- package/dist/vscode.html-custom.json +4834 -0
- package/package.json +9 -8
package/dist/browser/pacem-3d.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* @pacem/pacem v1.0.0-
|
|
3
|
-
*
|
|
1
|
+
/*!
|
|
2
|
+
* @pacem/pacem v1.0.0-amaldi (https://js.pacem.it)
|
|
3
|
+
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
(function (pacemFoundation, pacemCore, pacemNumerical) {
|
|
@@ -2300,35 +2300,35 @@
|
|
|
2300
2300
|
19, 3, 16, 19, 16, 17, 19, 18, 5, 19, 5, 1,
|
|
2301
2301
|
19, 1, 4, 18, 14, 10, 18, 10, 6, 18, 6, 5,
|
|
2302
2302
|
3, 2, 8, 3, 8, 12, 3, 12, 16];
|
|
2303
|
-
const textureCoordsString = `0.5 0.999501, 0.5 0.999501, 0.191292 0.808708, 0.5 0.690792,
|
|
2304
|
-
0.191292 0.808708, 0.191292 0.808708, 0.5 0.690792,
|
|
2305
|
-
0.808708 0.808708, 0.000499517 0.5, 0.309208 0.5, 0.5 0.309208,
|
|
2306
|
-
0.191292 0.191292, 0.191292 0.191292, 0.309208 0.5,
|
|
2307
|
-
0.191292 0.191292, 0.5 0.000499517, 0.5 0.309208, 0.808708 0.191292,
|
|
2308
|
-
0.000499517 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
2309
|
-
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
2310
|
-
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.309208 0.5,
|
|
2311
|
-
0.191292 0.191292, 0.5 0.000499517, 0.309208 0.5, 0.5 0.000499517,
|
|
2312
|
-
0.808708 0.191292, 0.309208 0.5, 0.808708 0.191292,
|
|
2313
|
-
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.690792 0.5,
|
|
2314
|
-
0.191292 0.808708, 0.690792 0.5, 0.808708 0.808708,
|
|
2315
|
-
0.191292 0.808708, 0.808708 0.808708, 0.808708 0.808708,
|
|
2316
|
-
0.5 0.690792, 0.5 0.309208, 0.808708 0.808708, 0.5 0.309208,
|
|
2317
|
-
0.808708 0.191292, 0.808708 0.191292, 0.9995 0.5, 0.191292 0.191292,
|
|
2318
|
-
0.5 0.000499517, 0.808708 0.191292, 0.191292 0.191292,
|
|
2319
|
-
0.808708 0.191292, 0.690792 0.5, 0.191292 0.191292,
|
|
2320
|
-
0.690792 0.5, 0.191292 0.191292, 0.5 0.000499517, 0.808708 0.191292,
|
|
2321
|
-
0.191292 0.191292, 0.808708 0.191292, 0.690792 0.5,
|
|
2322
|
-
0.690792 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
2323
|
-
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
2324
|
-
0.690792 0.5, 0.191292 0.808708, 0.5 0.000499517, 0.808708 0.191292,
|
|
2325
|
-
0.690792 0.5, 0.5 0.000499517, 0.690792 0.5, 0.309208 0.5,
|
|
2326
|
-
0.309208 0.5, 0.191292 0.191292, 0.9995 0.5, 0.808708 0.808708,
|
|
2327
|
-
0.5 0.690792, 0.9995 0.5, 0.5 0.690792, 0.5 0.309208,
|
|
2328
|
-
0.9995 0.5, 0.5 0.309208, 0.309208 0.5, 0.690792 0.5,
|
|
2329
|
-
0.808708 0.808708, 0.309208 0.5, 0.808708 0.808708,
|
|
2330
|
-
0.5 0.999501, 0.000499517 0.5, 0.5 0.309208, 0.000499517 0.5,
|
|
2331
|
-
0.5 0.690792, 0.5 0.690792, 0.000499517 0.5, 0.5 0.690792,
|
|
2303
|
+
const textureCoordsString = `0.5 0.999501, 0.5 0.999501, 0.191292 0.808708, 0.5 0.690792,
|
|
2304
|
+
0.191292 0.808708, 0.191292 0.808708, 0.5 0.690792,
|
|
2305
|
+
0.808708 0.808708, 0.000499517 0.5, 0.309208 0.5, 0.5 0.309208,
|
|
2306
|
+
0.191292 0.191292, 0.191292 0.191292, 0.309208 0.5,
|
|
2307
|
+
0.191292 0.191292, 0.5 0.000499517, 0.5 0.309208, 0.808708 0.191292,
|
|
2308
|
+
0.000499517 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
2309
|
+
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
2310
|
+
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.309208 0.5,
|
|
2311
|
+
0.191292 0.191292, 0.5 0.000499517, 0.309208 0.5, 0.5 0.000499517,
|
|
2312
|
+
0.808708 0.191292, 0.309208 0.5, 0.808708 0.191292,
|
|
2313
|
+
0.690792 0.5, 0.191292 0.808708, 0.309208 0.5, 0.690792 0.5,
|
|
2314
|
+
0.191292 0.808708, 0.690792 0.5, 0.808708 0.808708,
|
|
2315
|
+
0.191292 0.808708, 0.808708 0.808708, 0.808708 0.808708,
|
|
2316
|
+
0.5 0.690792, 0.5 0.309208, 0.808708 0.808708, 0.5 0.309208,
|
|
2317
|
+
0.808708 0.191292, 0.808708 0.191292, 0.9995 0.5, 0.191292 0.191292,
|
|
2318
|
+
0.5 0.000499517, 0.808708 0.191292, 0.191292 0.191292,
|
|
2319
|
+
0.808708 0.191292, 0.690792 0.5, 0.191292 0.191292,
|
|
2320
|
+
0.690792 0.5, 0.191292 0.191292, 0.5 0.000499517, 0.808708 0.191292,
|
|
2321
|
+
0.191292 0.191292, 0.808708 0.191292, 0.690792 0.5,
|
|
2322
|
+
0.690792 0.5, 0.309208 0.5, 0.690792 0.5, 0.808708 0.808708,
|
|
2323
|
+
0.5 0.999501, 0.690792 0.5, 0.5 0.999501, 0.191292 0.808708,
|
|
2324
|
+
0.690792 0.5, 0.191292 0.808708, 0.5 0.000499517, 0.808708 0.191292,
|
|
2325
|
+
0.690792 0.5, 0.5 0.000499517, 0.690792 0.5, 0.309208 0.5,
|
|
2326
|
+
0.309208 0.5, 0.191292 0.191292, 0.9995 0.5, 0.808708 0.808708,
|
|
2327
|
+
0.5 0.690792, 0.9995 0.5, 0.5 0.690792, 0.5 0.309208,
|
|
2328
|
+
0.9995 0.5, 0.5 0.309208, 0.309208 0.5, 0.690792 0.5,
|
|
2329
|
+
0.808708 0.808708, 0.309208 0.5, 0.808708 0.808708,
|
|
2330
|
+
0.5 0.999501, 0.000499517 0.5, 0.5 0.309208, 0.000499517 0.5,
|
|
2331
|
+
0.5 0.690792, 0.5 0.690792, 0.000499517 0.5, 0.5 0.690792,
|
|
2332
2332
|
0.191292 0.191292`;
|
|
2333
2333
|
const texIndices = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
|
2334
2334
|
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
|
|
@@ -3449,35 +3449,35 @@
|
|
|
3449
3449
|
const opts = pacemCore.Utils.extend({}, DefaultBasicMaterialFragmentOptions, options);
|
|
3450
3450
|
const definitions = adaptWGSLStringArray$1(extensions.definitions), bindings = adaptWGSLStringArray$1(extensions.bindings), modifiers = adaptWGSLModifierStringArray$1(extensions.modifiers);
|
|
3451
3451
|
const color = VERTEX_COLOR_REFERENCE, lighting = LIGHTING_COLOR_REFERENCE, ambient = AMBIENT_COLOR_REFERENCE;
|
|
3452
|
-
return `// definitions
|
|
3453
|
-
|
|
3454
|
-
${definitions}
|
|
3455
|
-
|
|
3456
|
-
// bindings
|
|
3457
|
-
@group(${opts.storageMaterialGroupIndex}) @binding(${opts.storageMaterialBindingIndex}) var<storage, read> diffuseColor: vec4f;
|
|
3458
|
-
${bindings}
|
|
3459
|
-
|
|
3460
|
-
const empty = vec4f(0,0,0,0);
|
|
3461
|
-
const white = vec4f(1,1,1,1);
|
|
3462
|
-
|
|
3463
|
-
@fragment fn main (
|
|
3464
|
-
@builtin(position) position: vec4f, // clip-space position
|
|
3465
|
-
@location(${opts.outputNormalLocation}) normal: vec3f, // world-space normal
|
|
3466
|
-
@location(${opts.outputVertexLocation}) vertex: vec3f, // world-space position
|
|
3467
|
-
@location(${opts.outputUvLocation}) uv: vec2f,
|
|
3468
|
-
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index: u32, // vertex index,
|
|
3469
|
-
@location(${opts.outputRayIndexLocation}) ray: vec3f, // ray (eye-to-vertex) vector
|
|
3470
|
-
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3471
|
-
) -> @location(0) vec4f {
|
|
3472
|
-
var ${color} = diffuseColor;
|
|
3473
|
-
var ${ambient}: vec4f = empty;
|
|
3474
|
-
var ${lighting}: vec4f = empty;
|
|
3475
|
-
|
|
3476
|
-
// modifiers
|
|
3477
|
-
${modifiers}
|
|
3478
|
-
|
|
3479
|
-
${lighting} = select(white, ${lighting}, ${lighting}.a > 0);
|
|
3480
|
-
return ${color} * ${lighting} + ${ambient};
|
|
3452
|
+
return `// definitions
|
|
3453
|
+
|
|
3454
|
+
${definitions}
|
|
3455
|
+
|
|
3456
|
+
// bindings
|
|
3457
|
+
@group(${opts.storageMaterialGroupIndex}) @binding(${opts.storageMaterialBindingIndex}) var<storage, read> diffuseColor: vec4f;
|
|
3458
|
+
${bindings}
|
|
3459
|
+
|
|
3460
|
+
const empty = vec4f(0,0,0,0);
|
|
3461
|
+
const white = vec4f(1,1,1,1);
|
|
3462
|
+
|
|
3463
|
+
@fragment fn main (
|
|
3464
|
+
@builtin(position) position: vec4f, // clip-space position
|
|
3465
|
+
@location(${opts.outputNormalLocation}) normal: vec3f, // world-space normal
|
|
3466
|
+
@location(${opts.outputVertexLocation}) vertex: vec3f, // world-space position
|
|
3467
|
+
@location(${opts.outputUvLocation}) uv: vec2f,
|
|
3468
|
+
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index: u32, // vertex index,
|
|
3469
|
+
@location(${opts.outputRayIndexLocation}) ray: vec3f, // ray (eye-to-vertex) vector
|
|
3470
|
+
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3471
|
+
) -> @location(0) vec4f {
|
|
3472
|
+
var ${color} = diffuseColor;
|
|
3473
|
+
var ${ambient}: vec4f = empty;
|
|
3474
|
+
var ${lighting}: vec4f = empty;
|
|
3475
|
+
|
|
3476
|
+
// modifiers
|
|
3477
|
+
${modifiers}
|
|
3478
|
+
|
|
3479
|
+
${lighting} = select(white, ${lighting}, ${lighting}.a > 0);
|
|
3480
|
+
return ${color} * ${lighting} + ${ambient};
|
|
3481
3481
|
}`;
|
|
3482
3482
|
}
|
|
3483
3483
|
|
|
@@ -3506,30 +3506,30 @@ const white = vec4f(1,1,1,1);
|
|
|
3506
3506
|
function getLineMaterialFragmentWgsl(extensions = {}, options = DefaultLineMaterialFragmentOptions) {
|
|
3507
3507
|
const opts = pacemCore.Utils.extend({}, DefaultLineMaterialFragmentOptions, options);
|
|
3508
3508
|
const definitions = adaptWGSLStringArray(extensions.definitions), bindings = adaptWGSLStringArray(extensions.bindings), modifiers = adaptWGSLModifierStringArray(extensions.modifiers);
|
|
3509
|
-
return `// definitions
|
|
3510
|
-
${definitions}
|
|
3511
|
-
|
|
3512
|
-
// bindings
|
|
3513
|
-
@group(${options.storageMaterialGroupIndex}) @binding(${options.storageMaterialBindingIndex}) var<storage, read> vertexColors: array<vec4f>;
|
|
3514
|
-
${bindings}
|
|
3515
|
-
|
|
3516
|
-
fn getVertexColor(index: u32) -> vec4f {
|
|
3517
|
-
let numColors = arrayLength(&vertexColors);
|
|
3518
|
-
let vertexColorIndex = index % numColors;
|
|
3519
|
-
return vertexColors[vertexColorIndex];
|
|
3520
|
-
}
|
|
3521
|
-
|
|
3522
|
-
@fragment fn main (
|
|
3523
|
-
@builtin(position) position: vec4f, // clip-space position
|
|
3524
|
-
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance: u32, // instance index
|
|
3525
|
-
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index: u32 // vertex index
|
|
3526
|
-
) -> @location(0) vec4f {
|
|
3527
|
-
var output = getVertexColor(index);
|
|
3528
|
-
|
|
3529
|
-
// modifiers
|
|
3530
|
-
${modifiers}
|
|
3531
|
-
|
|
3532
|
-
return output;
|
|
3509
|
+
return `// definitions
|
|
3510
|
+
${definitions}
|
|
3511
|
+
|
|
3512
|
+
// bindings
|
|
3513
|
+
@group(${options.storageMaterialGroupIndex}) @binding(${options.storageMaterialBindingIndex}) var<storage, read> vertexColors: array<vec4f>;
|
|
3514
|
+
${bindings}
|
|
3515
|
+
|
|
3516
|
+
fn getVertexColor(index: u32) -> vec4f {
|
|
3517
|
+
let numColors = arrayLength(&vertexColors);
|
|
3518
|
+
let vertexColorIndex = index % numColors;
|
|
3519
|
+
return vertexColors[vertexColorIndex];
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
@fragment fn main (
|
|
3523
|
+
@builtin(position) position: vec4f, // clip-space position
|
|
3524
|
+
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance: u32, // instance index
|
|
3525
|
+
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index: u32 // vertex index
|
|
3526
|
+
) -> @location(0) vec4f {
|
|
3527
|
+
var output = getVertexColor(index);
|
|
3528
|
+
|
|
3529
|
+
// modifiers
|
|
3530
|
+
${modifiers}
|
|
3531
|
+
|
|
3532
|
+
return output;
|
|
3533
3533
|
}`;
|
|
3534
3534
|
}
|
|
3535
3535
|
|
|
@@ -3688,8 +3688,8 @@ fn getVertexColor(index: u32) -> vec4f {
|
|
|
3688
3688
|
if (!pacemCore.Utils.isNullOrEmpty(modifierInput)) {
|
|
3689
3689
|
const { name: modifierName, args: [arg0, arg1], body: modifierBody } = extractMeshVertexModifierFunctionComponents(modifierInput);
|
|
3690
3690
|
modifyInstructionInput = `${modifierName}(vertexInput, interaction)`;
|
|
3691
|
-
modifierFnInput = `fn ${modifierName} (${arg0}: ${WGSL_VERTEXINPUT_STRUCT_NAME}, ${arg1}: ${WGSL_INTERACTIONDATA_STRUCT_NAME}) -> ${WGSL_VERTEXINPUT_STRUCT_NAME} {
|
|
3692
|
-
${modifierBody}
|
|
3691
|
+
modifierFnInput = `fn ${modifierName} (${arg0}: ${WGSL_VERTEXINPUT_STRUCT_NAME}, ${arg1}: ${WGSL_INTERACTIONDATA_STRUCT_NAME}) -> ${WGSL_VERTEXINPUT_STRUCT_NAME} {
|
|
3692
|
+
${modifierBody}
|
|
3693
3693
|
}`;
|
|
3694
3694
|
}
|
|
3695
3695
|
// vertex output modifier?
|
|
@@ -3698,74 +3698,74 @@ fn getVertexColor(index: u32) -> vec4f {
|
|
|
3698
3698
|
if (!pacemCore.Utils.isNullOrEmpty(modifierOutput)) {
|
|
3699
3699
|
const { name: modifierName, args: [arg0, arg1], body: modifierBody } = extractMeshVertexModifierFunctionComponents(modifierOutput);
|
|
3700
3700
|
modifyInstructionOutput = `${modifierName}(output, interaction)`;
|
|
3701
|
-
modifierFnOutput = `fn ${modifierName} (${arg0}: ${WGSL_VERTEXINPUT_STRUCT_NAME}, ${arg1}: ${WGSL_INTERACTIONDATA_STRUCT_NAME}) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3702
|
-
${modifierBody}
|
|
3701
|
+
modifierFnOutput = `fn ${modifierName} (${arg0}: ${WGSL_VERTEXINPUT_STRUCT_NAME}, ${arg1}: ${WGSL_INTERACTIONDATA_STRUCT_NAME}) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3702
|
+
${modifierBody}
|
|
3703
3703
|
}`;
|
|
3704
3704
|
}
|
|
3705
3705
|
const opts = pacemCore.Utils.extend({}, DefaultMeshVertexOptions, options);
|
|
3706
|
-
return `struct ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3707
|
-
@builtin(position) position : vec4f, // clip space position
|
|
3708
|
-
@location(${opts.outputNormalLocation}) normal: vec3f, // world space normal
|
|
3709
|
-
@location(${opts.outputVertexLocation}) vertex : vec3f, // world space position
|
|
3710
|
-
@location(${opts.outputUvLocation}) uv : vec2f, // texture coordinates
|
|
3711
|
-
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
3712
|
-
@location(${opts.outputRayLocation}) ray : vec3f, // eye-to-point vector in world space
|
|
3713
|
-
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3714
|
-
}
|
|
3715
|
-
|
|
3716
|
-
struct ${WGSL_VERTEXINPUT_STRUCT_NAME} {
|
|
3717
|
-
@location(${opts.inputPositionLocation}) position: vec3f,
|
|
3718
|
-
@location(${opts.inputNormalLocation}) normal: vec3f,
|
|
3719
|
-
@location(${opts.inputUvLocation}) uv: vec2f,
|
|
3720
|
-
@builtin(vertex_index) index: u32,
|
|
3721
|
-
@builtin(instance_index) instance: u32,
|
|
3722
|
-
}
|
|
3723
|
-
|
|
3724
|
-
struct Transforms {
|
|
3725
|
-
world: mat4x4f,
|
|
3726
|
-
normal: mat3x3f,
|
|
3727
|
-
}
|
|
3728
|
-
|
|
3729
|
-
struct Camera {
|
|
3730
|
-
view: mat4x4f,
|
|
3731
|
-
projection: mat4x4f,
|
|
3732
|
-
position: vec3f,
|
|
3733
|
-
}
|
|
3734
|
-
|
|
3735
|
-
struct ${WGSL_INTERACTIONDATA_STRUCT_NAME} {
|
|
3736
|
-
// mouse coordinatges in NDC space ([-1,1], [-1,1])
|
|
3737
|
-
cursor: vec2f,
|
|
3738
|
-
// canvas size in pixels
|
|
3739
|
-
resolution: vec2f,
|
|
3740
|
-
// some phase timer (e.g. time since mouse down, or time since last click, etc.)
|
|
3741
|
-
time: f32,
|
|
3742
|
-
}
|
|
3743
|
-
|
|
3744
|
-
${modifierFnInput}
|
|
3745
|
-
|
|
3746
|
-
${modifierFnOutput}
|
|
3747
|
-
|
|
3748
|
-
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3749
|
-
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3750
|
-
@group(${opts.uniformInteractionGroupIndex}) @binding(${opts.uniformInteractionBindingIndex}) var<uniform> interaction: ${WGSL_INTERACTIONDATA_STRUCT_NAME};
|
|
3751
|
-
|
|
3752
|
-
@vertex fn main(vertexInput: ${WGSL_VERTEXINPUT_STRUCT_NAME}) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3753
|
-
let input = ${modifyInstructionInput};
|
|
3754
|
-
let position4 = vec4f(input.position, 1.0);
|
|
3755
|
-
let worldTransform = transforms.world;
|
|
3756
|
-
let viewProjectionTransform = camera.projection;
|
|
3757
|
-
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3758
|
-
let worldPosition = (worldTransform * position4).xyz;
|
|
3759
|
-
let output = ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3760
|
-
worldViewProjectionTransform * position4,
|
|
3761
|
-
transforms.normal * input.normal,
|
|
3762
|
-
worldPosition,
|
|
3763
|
-
input.uv,
|
|
3764
|
-
input.index,
|
|
3765
|
-
normalize(worldPosition - camera.position),
|
|
3766
|
-
input.instance
|
|
3767
|
-
);
|
|
3768
|
-
return ${modifyInstructionOutput};
|
|
3706
|
+
return `struct ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3707
|
+
@builtin(position) position : vec4f, // clip space position
|
|
3708
|
+
@location(${opts.outputNormalLocation}) normal: vec3f, // world space normal
|
|
3709
|
+
@location(${opts.outputVertexLocation}) vertex : vec3f, // world space position
|
|
3710
|
+
@location(${opts.outputUvLocation}) uv : vec2f, // texture coordinates
|
|
3711
|
+
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
3712
|
+
@location(${opts.outputRayLocation}) ray : vec3f, // eye-to-point vector in world space
|
|
3713
|
+
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3716
|
+
struct ${WGSL_VERTEXINPUT_STRUCT_NAME} {
|
|
3717
|
+
@location(${opts.inputPositionLocation}) position: vec3f,
|
|
3718
|
+
@location(${opts.inputNormalLocation}) normal: vec3f,
|
|
3719
|
+
@location(${opts.inputUvLocation}) uv: vec2f,
|
|
3720
|
+
@builtin(vertex_index) index: u32,
|
|
3721
|
+
@builtin(instance_index) instance: u32,
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
struct Transforms {
|
|
3725
|
+
world: mat4x4f,
|
|
3726
|
+
normal: mat3x3f,
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
struct Camera {
|
|
3730
|
+
view: mat4x4f,
|
|
3731
|
+
projection: mat4x4f,
|
|
3732
|
+
position: vec3f,
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
struct ${WGSL_INTERACTIONDATA_STRUCT_NAME} {
|
|
3736
|
+
// mouse coordinatges in NDC space ([-1,1], [-1,1])
|
|
3737
|
+
cursor: vec2f,
|
|
3738
|
+
// canvas size in pixels
|
|
3739
|
+
resolution: vec2f,
|
|
3740
|
+
// some phase timer (e.g. time since mouse down, or time since last click, etc.)
|
|
3741
|
+
time: f32,
|
|
3742
|
+
}
|
|
3743
|
+
|
|
3744
|
+
${modifierFnInput}
|
|
3745
|
+
|
|
3746
|
+
${modifierFnOutput}
|
|
3747
|
+
|
|
3748
|
+
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3749
|
+
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3750
|
+
@group(${opts.uniformInteractionGroupIndex}) @binding(${opts.uniformInteractionBindingIndex}) var<uniform> interaction: ${WGSL_INTERACTIONDATA_STRUCT_NAME};
|
|
3751
|
+
|
|
3752
|
+
@vertex fn main(vertexInput: ${WGSL_VERTEXINPUT_STRUCT_NAME}) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3753
|
+
let input = ${modifyInstructionInput};
|
|
3754
|
+
let position4 = vec4f(input.position, 1.0);
|
|
3755
|
+
let worldTransform = transforms.world;
|
|
3756
|
+
let viewProjectionTransform = camera.projection;
|
|
3757
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3758
|
+
let worldPosition = (worldTransform * position4).xyz;
|
|
3759
|
+
let output = ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3760
|
+
worldViewProjectionTransform * position4,
|
|
3761
|
+
transforms.normal * input.normal,
|
|
3762
|
+
worldPosition,
|
|
3763
|
+
input.uv,
|
|
3764
|
+
input.index,
|
|
3765
|
+
normalize(worldPosition - camera.position),
|
|
3766
|
+
input.instance
|
|
3767
|
+
);
|
|
3768
|
+
return ${modifyInstructionOutput};
|
|
3769
3769
|
}`;
|
|
3770
3770
|
}
|
|
3771
3771
|
|
|
@@ -3783,160 +3783,160 @@ ${modifierFnOutput}
|
|
|
3783
3783
|
uniformWorldBindingIndex: UNIFORM_BINDING_INDEX_TRANSFORM,
|
|
3784
3784
|
};
|
|
3785
3785
|
function getVertexOutputStructDefinition(opts) {
|
|
3786
|
-
return `struct ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3787
|
-
@builtin(position) position : vec4f, // clip space position
|
|
3788
|
-
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3789
|
-
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
3786
|
+
return `struct ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3787
|
+
@builtin(position) position : vec4f, // clip space position
|
|
3788
|
+
@location(${opts.outputInstanceIndexLocation}) @interpolate(flat) instance : u32, // instance index
|
|
3789
|
+
@location(${opts.outputVertexIndexLocation}) @interpolate(flat) index : u32, // vertex index
|
|
3790
3790
|
}`;
|
|
3791
3791
|
}
|
|
3792
3792
|
function getDefaultLineVertexWgsl(options = DefaultLineVertexOptions) {
|
|
3793
3793
|
const opts = pacemCore.Utils.extend({}, DefaultLineVertexOptions, options);
|
|
3794
|
-
return `${getVertexOutputStructDefinition(opts)}
|
|
3795
|
-
|
|
3796
|
-
struct Transforms {
|
|
3797
|
-
world: mat4x4f,
|
|
3798
|
-
normal: mat3x3f,
|
|
3799
|
-
}
|
|
3800
|
-
|
|
3801
|
-
struct Camera {
|
|
3802
|
-
view: mat4x4f,
|
|
3803
|
-
projection: mat4x4f,
|
|
3804
|
-
position: vec3f
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3807
|
-
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3808
|
-
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3809
|
-
@group(${opts.storagePositionsGroupIndex}) @binding(${opts.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
3810
|
-
|
|
3811
|
-
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
3812
|
-
@builtin(vertex_index) index: u32) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3813
|
-
|
|
3814
|
-
let x = positions[3u * index + 0u];
|
|
3815
|
-
let y = positions[3u * index + 1u];
|
|
3816
|
-
let z = positions[3u * index + 2u];
|
|
3817
|
-
let position4 = vec4f(x, y, z, 1.0);
|
|
3818
|
-
let worldTransform = transforms.world;
|
|
3819
|
-
let viewProjectionTransform = camera.projection;
|
|
3820
|
-
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3821
|
-
let worldPosition = (worldTransform * position4).xyz;
|
|
3822
|
-
return ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3823
|
-
worldViewProjectionTransform * position4,
|
|
3824
|
-
instance,
|
|
3825
|
-
index);
|
|
3794
|
+
return `${getVertexOutputStructDefinition(opts)}
|
|
3795
|
+
|
|
3796
|
+
struct Transforms {
|
|
3797
|
+
world: mat4x4f,
|
|
3798
|
+
normal: mat3x3f,
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3801
|
+
struct Camera {
|
|
3802
|
+
view: mat4x4f,
|
|
3803
|
+
projection: mat4x4f,
|
|
3804
|
+
position: vec3f
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3807
|
+
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3808
|
+
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3809
|
+
@group(${opts.storagePositionsGroupIndex}) @binding(${opts.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
3810
|
+
|
|
3811
|
+
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
3812
|
+
@builtin(vertex_index) index: u32) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3813
|
+
|
|
3814
|
+
let x = positions[3u * index + 0u];
|
|
3815
|
+
let y = positions[3u * index + 1u];
|
|
3816
|
+
let z = positions[3u * index + 2u];
|
|
3817
|
+
let position4 = vec4f(x, y, z, 1.0);
|
|
3818
|
+
let worldTransform = transforms.world;
|
|
3819
|
+
let viewProjectionTransform = camera.projection;
|
|
3820
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3821
|
+
let worldPosition = (worldTransform * position4).xyz;
|
|
3822
|
+
return ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3823
|
+
worldViewProjectionTransform * position4,
|
|
3824
|
+
instance,
|
|
3825
|
+
index);
|
|
3826
3826
|
}`;
|
|
3827
3827
|
}
|
|
3828
3828
|
function getFatLineVertexWgsl(options = DefaultLineVertexOptions) {
|
|
3829
3829
|
const opts = pacemCore.Utils.extend({}, DefaultLineVertexOptions, options);
|
|
3830
|
-
return `${getVertexOutputStructDefinition(opts)}
|
|
3831
|
-
|
|
3832
|
-
struct Transforms {
|
|
3833
|
-
world: mat4x4f,
|
|
3834
|
-
normal: mat3x3f,
|
|
3835
|
-
}
|
|
3836
|
-
|
|
3837
|
-
struct Camera {
|
|
3838
|
-
view: mat4x4f,
|
|
3839
|
-
projection: mat4x4f,
|
|
3840
|
-
position: vec3f
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
struct Pixels {
|
|
3844
|
-
viewportWidth: f32,
|
|
3845
|
-
viewportHeight: f32,
|
|
3846
|
-
halfLineWidth: f32
|
|
3847
|
-
}
|
|
3848
|
-
|
|
3849
|
-
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3850
|
-
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3851
|
-
@group(${opts.storagePositionsGroupIndex}) @binding(${opts.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
3852
|
-
@group(${opts.uniformDimensionsGroupIndex}) @binding(${opts.uniformDimensionsBindingIndex}) var<uniform> dimensions: Pixels;
|
|
3853
|
-
|
|
3854
|
-
fn computeClipPosition(index: u32) -> vec4f {
|
|
3855
|
-
let x = positions[3u * index + 0u];
|
|
3856
|
-
let y = positions[3u * index + 1u];
|
|
3857
|
-
let z = positions[3u * index + 2u];
|
|
3858
|
-
let position4 = vec4f(x, y, z, 1.0);
|
|
3859
|
-
let worldTransform = transforms.world;
|
|
3860
|
-
let viewProjectionTransform = camera.projection;
|
|
3861
|
-
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3862
|
-
return worldViewProjectionTransform * position4;
|
|
3863
|
-
}
|
|
3864
|
-
|
|
3865
|
-
fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
3866
|
-
|
|
3867
|
-
let viewportSize = vec2f(dimensions.viewportWidth, dimensions.viewportHeight);
|
|
3868
|
-
let normalizedSize = normalize(viewportSize);
|
|
3869
|
-
let halfThickness = dimensions.halfLineWidth / dimensions.viewportWidth;
|
|
3870
|
-
let p0ndc = p0.xyz / p0.w;
|
|
3871
|
-
let p1ndc = p1.xyz / p1.w;
|
|
3872
|
-
let dir = normalize((p1ndc - p0ndc).xy);
|
|
3873
|
-
let offsetX = halfThickness * 2.0 / normalizedSize.x;
|
|
3874
|
-
let offsetY = halfThickness * 2.0 / normalizedSize.y;
|
|
3875
|
-
|
|
3876
|
-
// perp
|
|
3877
|
-
let perp0 = vec2f(-dir.y * offsetX, dir.x * offsetY);
|
|
3878
|
-
let perp1 = perp0;
|
|
3879
|
-
|
|
3880
|
-
/*
|
|
3881
|
-
|
|
3882
|
-
position0-0 -----*----- position0-1
|
|
3883
|
-
|\\ |
|
|
3884
|
-
| \\ |
|
|
3885
|
-
| \\ |
|
|
3886
|
-
| \\ |
|
|
3887
|
-
| \\ |
|
|
3888
|
-
| \\ |
|
|
3889
|
-
| \\ |
|
|
3890
|
-
| \\|
|
|
3891
|
-
position1-0 -----*----- position1-1
|
|
3892
|
-
|
|
3893
|
-
indexes:
|
|
3894
|
-
------------
|
|
3895
|
-
p0-0 -> 0, 3
|
|
3896
|
-
p0-1 -> 5
|
|
3897
|
-
p1-0 -> 1
|
|
3898
|
-
p1-1 -> 2, 4
|
|
3899
|
-
*/
|
|
3900
|
-
|
|
3901
|
-
var outPos: vec2f;
|
|
3902
|
-
var w = p0.w;
|
|
3903
|
-
var z = p0.z;
|
|
3904
|
-
if (index == 0 || index == 3){
|
|
3905
|
-
outPos = p0ndc.xy - perp0;
|
|
3906
|
-
}
|
|
3907
|
-
else if (index == 1){
|
|
3908
|
-
outPos = p1ndc.xy - perp1;
|
|
3909
|
-
w = p1.w;
|
|
3910
|
-
z = p1.z;
|
|
3911
|
-
}
|
|
3912
|
-
else if (index == 5){
|
|
3913
|
-
outPos = p0ndc.xy + perp0;
|
|
3914
|
-
}
|
|
3915
|
-
else { //if (index == 2 || index == 4)
|
|
3916
|
-
outPos = p1ndc.xy + perp1;
|
|
3917
|
-
w = p1.w;
|
|
3918
|
-
z = p1.z;
|
|
3919
|
-
}
|
|
3920
|
-
|
|
3921
|
-
// return vec4f(outPos , 0, 1.0);
|
|
3922
|
-
return vec4f(outPos * w, z, w);
|
|
3923
|
-
}
|
|
3924
|
-
|
|
3925
|
-
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
3926
|
-
@builtin(vertex_index) index: u32) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3927
|
-
|
|
3928
|
-
// vertex index starting at 1
|
|
3929
|
-
let position0 = computeClipPosition(instance);
|
|
3930
|
-
let position1 = computeClipPosition(instance + 1);
|
|
3931
|
-
|
|
3932
|
-
// apply offset
|
|
3933
|
-
let position = computeOffsetPosition(position0, position1, index);
|
|
3934
|
-
|
|
3935
|
-
return ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3936
|
-
position,
|
|
3937
|
-
instance,
|
|
3938
|
-
index
|
|
3939
|
-
);
|
|
3830
|
+
return `${getVertexOutputStructDefinition(opts)}
|
|
3831
|
+
|
|
3832
|
+
struct Transforms {
|
|
3833
|
+
world: mat4x4f,
|
|
3834
|
+
normal: mat3x3f,
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
struct Camera {
|
|
3838
|
+
view: mat4x4f,
|
|
3839
|
+
projection: mat4x4f,
|
|
3840
|
+
position: vec3f
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
struct Pixels {
|
|
3844
|
+
viewportWidth: f32,
|
|
3845
|
+
viewportHeight: f32,
|
|
3846
|
+
halfLineWidth: f32
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
@group(${opts.uniformWorldGroupIndex}) @binding(${opts.uniformWorldBindingIndex}) var<uniform> transforms: Transforms;
|
|
3850
|
+
@group(${opts.uniformViewGroupIndex}) @binding(${opts.uniformViewBindingIndex}) var<uniform> camera: Camera;
|
|
3851
|
+
@group(${opts.storagePositionsGroupIndex}) @binding(${opts.storagePositionsBindingIndex}) var<storage, read> positions: array<f32>;
|
|
3852
|
+
@group(${opts.uniformDimensionsGroupIndex}) @binding(${opts.uniformDimensionsBindingIndex}) var<uniform> dimensions: Pixels;
|
|
3853
|
+
|
|
3854
|
+
fn computeClipPosition(index: u32) -> vec4f {
|
|
3855
|
+
let x = positions[3u * index + 0u];
|
|
3856
|
+
let y = positions[3u * index + 1u];
|
|
3857
|
+
let z = positions[3u * index + 2u];
|
|
3858
|
+
let position4 = vec4f(x, y, z, 1.0);
|
|
3859
|
+
let worldTransform = transforms.world;
|
|
3860
|
+
let viewProjectionTransform = camera.projection;
|
|
3861
|
+
let worldViewProjectionTransform = viewProjectionTransform * worldTransform;
|
|
3862
|
+
return worldViewProjectionTransform * position4;
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
3866
|
+
|
|
3867
|
+
let viewportSize = vec2f(dimensions.viewportWidth, dimensions.viewportHeight);
|
|
3868
|
+
let normalizedSize = normalize(viewportSize);
|
|
3869
|
+
let halfThickness = dimensions.halfLineWidth / dimensions.viewportWidth;
|
|
3870
|
+
let p0ndc = p0.xyz / p0.w;
|
|
3871
|
+
let p1ndc = p1.xyz / p1.w;
|
|
3872
|
+
let dir = normalize((p1ndc - p0ndc).xy);
|
|
3873
|
+
let offsetX = halfThickness * 2.0 / normalizedSize.x;
|
|
3874
|
+
let offsetY = halfThickness * 2.0 / normalizedSize.y;
|
|
3875
|
+
|
|
3876
|
+
// perp
|
|
3877
|
+
let perp0 = vec2f(-dir.y * offsetX, dir.x * offsetY);
|
|
3878
|
+
let perp1 = perp0;
|
|
3879
|
+
|
|
3880
|
+
/*
|
|
3881
|
+
|
|
3882
|
+
position0-0 -----*----- position0-1
|
|
3883
|
+
|\\ |
|
|
3884
|
+
| \\ |
|
|
3885
|
+
| \\ |
|
|
3886
|
+
| \\ |
|
|
3887
|
+
| \\ |
|
|
3888
|
+
| \\ |
|
|
3889
|
+
| \\ |
|
|
3890
|
+
| \\|
|
|
3891
|
+
position1-0 -----*----- position1-1
|
|
3892
|
+
|
|
3893
|
+
indexes:
|
|
3894
|
+
------------
|
|
3895
|
+
p0-0 -> 0, 3
|
|
3896
|
+
p0-1 -> 5
|
|
3897
|
+
p1-0 -> 1
|
|
3898
|
+
p1-1 -> 2, 4
|
|
3899
|
+
*/
|
|
3900
|
+
|
|
3901
|
+
var outPos: vec2f;
|
|
3902
|
+
var w = p0.w;
|
|
3903
|
+
var z = p0.z;
|
|
3904
|
+
if (index == 0 || index == 3){
|
|
3905
|
+
outPos = p0ndc.xy - perp0;
|
|
3906
|
+
}
|
|
3907
|
+
else if (index == 1){
|
|
3908
|
+
outPos = p1ndc.xy - perp1;
|
|
3909
|
+
w = p1.w;
|
|
3910
|
+
z = p1.z;
|
|
3911
|
+
}
|
|
3912
|
+
else if (index == 5){
|
|
3913
|
+
outPos = p0ndc.xy + perp0;
|
|
3914
|
+
}
|
|
3915
|
+
else { //if (index == 2 || index == 4)
|
|
3916
|
+
outPos = p1ndc.xy + perp1;
|
|
3917
|
+
w = p1.w;
|
|
3918
|
+
z = p1.z;
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
// return vec4f(outPos , 0, 1.0);
|
|
3922
|
+
return vec4f(outPos * w, z, w);
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
@vertex fn main(@builtin(instance_index) instance: u32,
|
|
3926
|
+
@builtin(vertex_index) index: u32) -> ${WGSL_VERTEXOUTPUT_STRUCT_NAME} {
|
|
3927
|
+
|
|
3928
|
+
// vertex index starting at 1
|
|
3929
|
+
let position0 = computeClipPosition(instance);
|
|
3930
|
+
let position1 = computeClipPosition(instance + 1);
|
|
3931
|
+
|
|
3932
|
+
// apply offset
|
|
3933
|
+
let position = computeOffsetPosition(position0, position1, index);
|
|
3934
|
+
|
|
3935
|
+
return ${WGSL_VERTEXOUTPUT_STRUCT_NAME}(
|
|
3936
|
+
position,
|
|
3937
|
+
instance,
|
|
3938
|
+
index
|
|
3939
|
+
);
|
|
3940
3940
|
}`;
|
|
3941
3941
|
}
|
|
3942
3942
|
|
|
@@ -3945,16 +3945,16 @@ fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
|
3945
3945
|
* Generate a WGSL piece of code that eases 3D picking using color strategy.
|
|
3946
3946
|
*/
|
|
3947
3947
|
function getColorPickingFragmentWgsl(groupIndex = UNIFORM_GROUP_INDEX_COLORPICKING) {
|
|
3948
|
-
return `struct ColorPicker {
|
|
3949
|
-
id: u32,
|
|
3950
|
-
};
|
|
3951
|
-
|
|
3952
|
-
@group(${groupIndex}) @binding(0) var<uniform> colorPicker: ColorPicker;
|
|
3953
|
-
|
|
3954
|
-
@fragment
|
|
3955
|
-
fn main(@builtin(position) position: vec4f) -> @location(0) u32 {
|
|
3956
|
-
return colorPicker.id;
|
|
3957
|
-
}
|
|
3948
|
+
return `struct ColorPicker {
|
|
3949
|
+
id: u32,
|
|
3950
|
+
};
|
|
3951
|
+
|
|
3952
|
+
@group(${groupIndex}) @binding(0) var<uniform> colorPicker: ColorPicker;
|
|
3953
|
+
|
|
3954
|
+
@fragment
|
|
3955
|
+
fn main(@builtin(position) position: vec4f) -> @location(0) u32 {
|
|
3956
|
+
return colorPicker.id;
|
|
3957
|
+
}
|
|
3958
3958
|
`;
|
|
3959
3959
|
}
|
|
3960
3960
|
|
|
@@ -3997,16 +3997,16 @@ fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
|
3997
3997
|
}
|
|
3998
3998
|
return {
|
|
3999
3999
|
// type definitions
|
|
4000
|
-
definitions: [`struct DirectionalLight {
|
|
4001
|
-
color: vec4f,
|
|
4002
|
-
direction: vec3f,
|
|
4003
|
-
intensity: f32
|
|
4004
|
-
}`, `fn computeDirectional(normal: vec3f, color: vec4f, light: DirectionalLight) -> vec4f {
|
|
4005
|
-
let n = normalize(normal);
|
|
4006
|
-
let d = normalize(light.direction);
|
|
4007
|
-
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
4008
|
-
let output = color.rgb * light.color.rgb * factor;
|
|
4009
|
-
return vec4f(output, color.a);
|
|
4000
|
+
definitions: [`struct DirectionalLight {
|
|
4001
|
+
color: vec4f,
|
|
4002
|
+
direction: vec3f,
|
|
4003
|
+
intensity: f32
|
|
4004
|
+
}`, `fn computeDirectional(normal: vec3f, color: vec4f, light: DirectionalLight) -> vec4f {
|
|
4005
|
+
let n = normalize(normal);
|
|
4006
|
+
let d = normalize(light.direction);
|
|
4007
|
+
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
4008
|
+
let output = color.rgb * light.color.rgb * factor;
|
|
4009
|
+
return vec4f(output, color.a);
|
|
4010
4010
|
}`],
|
|
4011
4011
|
// bindings
|
|
4012
4012
|
bindings: [`@group(${group}) @binding(${binding}) var<uniform> ${lightReference}: DirectionalLight;`],
|
|
@@ -4028,24 +4028,24 @@ fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
|
4028
4028
|
}
|
|
4029
4029
|
return {
|
|
4030
4030
|
// type definitions
|
|
4031
|
-
definitions: [`struct OmniLight {
|
|
4032
|
-
color: vec4f,
|
|
4033
|
-
position: vec3f,
|
|
4034
|
-
intensity: f32
|
|
4035
|
-
}`, `fn computeOmni(position: vec3f, normal: vec3f, ray: vec3f, color: vec4f, specularColor: vec4f, shininess: f32, light: OmniLight) -> vec4f {
|
|
4036
|
-
|
|
4037
|
-
// color
|
|
4038
|
-
let n = normalize(normal);
|
|
4039
|
-
let d = normalize(position - light.position);
|
|
4040
|
-
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
4041
|
-
|
|
4042
|
-
// specular
|
|
4043
|
-
let r = normalize(ray);
|
|
4044
|
-
let halfVector = normalize(d + r);
|
|
4045
|
-
let specular = specularColor.rgb * shininess * dot(n, -halfVector);
|
|
4046
|
-
|
|
4047
|
-
let output = color.rgb * light.color.rgb * factor + specular;
|
|
4048
|
-
return vec4f(output, color.a);
|
|
4031
|
+
definitions: [`struct OmniLight {
|
|
4032
|
+
color: vec4f,
|
|
4033
|
+
position: vec3f,
|
|
4034
|
+
intensity: f32
|
|
4035
|
+
}`, `fn computeOmni(position: vec3f, normal: vec3f, ray: vec3f, color: vec4f, specularColor: vec4f, shininess: f32, light: OmniLight) -> vec4f {
|
|
4036
|
+
|
|
4037
|
+
// color
|
|
4038
|
+
let n = normalize(normal);
|
|
4039
|
+
let d = normalize(position - light.position);
|
|
4040
|
+
let factor = light.intensity * .5 * (1.0 + dot(n, -d));
|
|
4041
|
+
|
|
4042
|
+
// specular
|
|
4043
|
+
let r = normalize(ray);
|
|
4044
|
+
let halfVector = normalize(d + r);
|
|
4045
|
+
let specular = specularColor.rgb * shininess * dot(n, -halfVector);
|
|
4046
|
+
|
|
4047
|
+
let output = color.rgb * light.color.rgb * factor + specular;
|
|
4048
|
+
return vec4f(output, color.a);
|
|
4049
4049
|
}`],
|
|
4050
4050
|
// bindings
|
|
4051
4051
|
bindings: [`@group(${group}) @binding(${binding}) var<uniform> ${lightReference}: OmniLight;`],
|
|
@@ -4063,11 +4063,11 @@ fn computeOffsetPosition(p0: vec4f, p1: vec4f, index: u32) -> vec4f {
|
|
|
4063
4063
|
}
|
|
4064
4064
|
return {
|
|
4065
4065
|
// type definitions
|
|
4066
|
-
definitions: [`struct AmbientLight {
|
|
4067
|
-
color: vec4f,
|
|
4068
|
-
intensity: f32
|
|
4069
|
-
}`, `fn computeAmbient(color: vec4f, light: AmbientLight) -> vec4f {
|
|
4070
|
-
return vec4f(light.intensity * color.rgb * light.color.rgb, color.a);
|
|
4066
|
+
definitions: [`struct AmbientLight {
|
|
4067
|
+
color: vec4f,
|
|
4068
|
+
intensity: f32
|
|
4069
|
+
}`, `fn computeAmbient(color: vec4f, light: AmbientLight) -> vec4f {
|
|
4070
|
+
return vec4f(light.intensity * color.rgb * light.color.rgb, color.a);
|
|
4071
4071
|
}`],
|
|
4072
4072
|
// bindings
|
|
4073
4073
|
bindings: [`@group(${group}) @binding(${binding}) var<uniform> ${lightReference}: AmbientLight;`],
|