@tolokoban/tgd 2.0.31 → 2.0.32

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.
Files changed (33) hide show
  1. package/lib/dist/context/context.d.ts +11 -2
  2. package/lib/dist/context/context.d.ts.map +1 -1
  3. package/lib/dist/context/context.js +32 -13
  4. package/lib/dist/material/depth.d.ts +18 -0
  5. package/lib/dist/material/depth.d.ts.map +1 -0
  6. package/lib/dist/material/depth.js +24 -0
  7. package/lib/dist/material/index.d.ts +1 -0
  8. package/lib/dist/material/index.d.ts.map +1 -1
  9. package/lib/dist/material/index.js +2 -1
  10. package/lib/dist/painter/background-with-depth/background-with-depth.d.ts +30 -8
  11. package/lib/dist/painter/background-with-depth/background-with-depth.d.ts.map +1 -1
  12. package/lib/dist/painter/background-with-depth/background-with-depth.js +71 -72
  13. package/lib/dist/painter/background-with-depth/background.frag +13 -4
  14. package/lib/dist/painter/background-with-depth/background.vert +3 -0
  15. package/lib/dist/painter/framebuffer-msaa.js +1 -1
  16. package/lib/dist/painter/framebuffer.d.ts +3 -5
  17. package/lib/dist/painter/framebuffer.d.ts.map +1 -1
  18. package/lib/dist/painter/framebuffer.js +7 -17
  19. package/lib/dist/texture/index.d.ts +1 -0
  20. package/lib/dist/texture/index.d.ts.map +1 -1
  21. package/lib/dist/texture/index.js +2 -1
  22. package/lib/dist/texture/texture-depth.d.ts +12 -26
  23. package/lib/dist/texture/texture-depth.d.ts.map +1 -1
  24. package/lib/dist/texture/texture-depth.js +44 -60
  25. package/lib/dist/texture/texture2d.d.ts +5 -2
  26. package/lib/dist/texture/texture2d.d.ts.map +1 -1
  27. package/lib/dist/texture/texture2d.js +3 -2
  28. package/lib/dist/utils/state/depth.d.ts +1 -1
  29. package/lib/dist/utils/state/depth.d.ts.map +1 -1
  30. package/lib/dist/utils/state/depth.js +8 -1
  31. package/package.json +5 -1
  32. package/lib/dist/painter/segments/segments.frag +0 -22
  33. package/lib/dist/painter/segments/segments.vert +0 -121
@@ -1,121 +0,0 @@
1
- #version 300 es
2
-
3
- precision highp float;
4
-
5
- uniform sampler2D uniTexture;
6
- uniform mat4 uniModelViewMatrix;
7
- uniform mat4 uniProjectionMatrix;
8
- // Minimal value for the radius.
9
- uniform float uniMinRadius;
10
- // Multiply all radii by this value.
11
- uniform float uniRadiusMultiplier;
12
- // When uniRadiusSwitch == 1.0,
13
- // we use uniRadiusConstant as radius.
14
- uniform float uniRadiusConstant;
15
- // 0.0 means we will use the radius defined
16
- // in the attribute attAxyzr or attBaxyz.
17
- // 1.0 means we use uniRadiusConstant for
18
- // all vertices.
19
- uniform float uniRadiusSwitch;
20
- // Multiply the color by this value;
21
- uniform float uniLight;
22
- // Push the segments away from camera of `uniShiftZ`.
23
- // This can be used if you want contours on the segments:
24
- // just increase `uniRadiusMultiplier`, set a low `uniLight`,
25
- // and set a small positive `uniShiftZ`.
26
- uniform float uniShiftZ;
27
-
28
- //===================
29
- // Vertex attributes
30
- //-------------------
31
-
32
- // Position of the vertex, relative to
33
- // the current center and assuming a
34
- // radius of 1.
35
- // Z tells you what tip is your center: 0 for A and 1 for B.
36
- in vec3 attOffset;
37
- // Normals of the tube that represents the segment.
38
- in vec3 attNormal;
39
-
40
- //=====================
41
- // Instance attributes
42
- //---------------------
43
-
44
- // Coords and radious of tip A.
45
- in vec4 attAxyzr;
46
- // Coords and radious of tip B.
47
- in vec4 attBxyzr;
48
- // The color is taken from a texture.
49
- in vec2 attAuv;
50
- in vec2 attBuv;
51
- // 0 means that nothing modifies the initial radius,
52
- // except the minRadius.
53
- in float attAinfluence;
54
- in float attBinfluence;
55
-
56
-
57
- out vec4 varColor;
58
- out vec3 varNormal;
59
-
60
-
61
- vec3 worldToCamera(vec3 v);
62
- float getRadius(float tip);
63
- mat3 getTransfoMatrix(float tip, vec3 camA, vec3 camB);
64
-
65
- void main() {
66
- vec3 camA = worldToCamera(attAxyzr.xyz);
67
- vec3 camB = worldToCamera(attBxyzr.xyz);
68
- float tip = attOffset.z;
69
- float radius = getRadius(tip);
70
- mat3 transfo = getTransfoMatrix(tip, camA, camB);
71
- vec3 point = transfo * vec3(attOffset.xy * radius, 1.0);
72
- varNormal = attNormal;
73
- point.z -= uniShiftZ + abs(attOffset.y) * radius;
74
- gl_Position =
75
- uniProjectionMatrix
76
- * vec4(point, 1);
77
- vec2 uv = mix(attAuv, attBuv, tip);
78
- // float Z = 1.0 - abs(point.z) * 0.0001;
79
- // Z = pow(Z, 0.025);
80
- float light = uniLight; // * Z;
81
- varColor = texture(uniTexture, uv) * vec4(vec3(light), 1.0);
82
- // varColor = vec4(vec3(1.0 - Z, Z, 0.0), varColor.a);
83
- }
84
-
85
- float getRadius(float tip) {
86
- float influence = mix(attAinfluence, attBinfluence, tip);
87
- float originalRadius = mix(
88
- attAxyzr.w,
89
- attBxyzr.w,
90
- tip
91
- );
92
- float modifiedRadius = mix(
93
- originalRadius,
94
- uniRadiusConstant,
95
- uniRadiusSwitch
96
- ) * uniRadiusMultiplier;
97
- float radius = mix(
98
- originalRadius,
99
- modifiedRadius,
100
- influence
101
- );
102
- return max(uniMinRadius, radius);
103
- }
104
-
105
- vec3 worldToCamera(vec3 v) {
106
- vec4 result = uniModelViewMatrix * vec4(v, 1.0);
107
- return result.xyz;
108
- }
109
-
110
- mat3 getTransfoMatrix(float tip, vec3 camA, vec3 camB) {
111
- // What is the current tip?
112
- vec3 camO = mix(camA, camB, tip);
113
- vec2 A = camA.xy;
114
- vec2 B = camB.xy;
115
- vec3 Y = vec3(
116
- A == B ? vec2(0, 1) : normalize(A - B),
117
- 0
118
- );
119
- vec3 X = vec3(Y.y, -Y.x, 0);
120
- return mat3(X, Y, camO);
121
- }