viral-viewer-2 6.0.8 → 6.1.0

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 (111) hide show
  1. package/dist/components/camera/viral-camera.d.ts +1 -1
  2. package/dist/components/custom-objects/viral-instanced-mesh.d.ts +2 -1
  3. package/dist/components/custom-objects/viral-instanced-mesh.js +5 -3
  4. package/dist/components/custom-objects/viral-instanced-mesh.js.map +1 -1
  5. package/dist/components/event-handler/keyboard/viral-keyboard.d.ts +17 -0
  6. package/dist/components/event-handler/keyboard/viral-keyboard.js +76 -0
  7. package/dist/components/event-handler/keyboard/viral-keyboard.js.map +1 -0
  8. package/dist/components/event-handler/mouse/viral-mouse.d.ts +31 -0
  9. package/dist/components/event-handler/mouse/viral-mouse.js +234 -0
  10. package/dist/components/event-handler/mouse/viral-mouse.js.map +1 -0
  11. package/dist/components/loader/viral-three.loader.d.ts +1 -1
  12. package/dist/components/post-processing/ambient-occlusion-effect.d.ts +0 -2
  13. package/dist/components/post-processing/ambient-occlusion-effect.js +1 -2
  14. package/dist/components/post-processing/ambient-occlusion-effect.js.map +1 -1
  15. package/dist/components/post-processing/viral-post-processing.d.ts +11 -0
  16. package/dist/components/post-processing/viral-post-processing.js +29 -0
  17. package/dist/components/post-processing/viral-post-processing.js.map +1 -0
  18. package/dist/components/scene/viral-scene.d.ts +1 -1
  19. package/dist/gui/context-menu/viral-context-menu.d.ts +17 -0
  20. package/dist/gui/context-menu/viral-context-menu.js +74 -0
  21. package/dist/gui/context-menu/viral-context-menu.js.map +1 -0
  22. package/dist/gui/draggable-modal/viral-draggable-modal.d.ts +11 -0
  23. package/dist/gui/draggable-modal/viral-draggable-modal.js +91 -0
  24. package/dist/gui/draggable-modal/viral-draggable-modal.js.map +1 -0
  25. package/dist/gui/navigation-cube/components/cube-camera.d.ts +15 -0
  26. package/dist/gui/navigation-cube/components/cube-camera.js +74 -0
  27. package/dist/gui/navigation-cube/components/cube-camera.js.map +1 -0
  28. package/dist/gui/navigation-cube/components/cube-renderer.d.ts +9 -0
  29. package/dist/gui/navigation-cube/components/cube-renderer.js +31 -0
  30. package/dist/gui/navigation-cube/components/cube-renderer.js.map +1 -0
  31. package/dist/gui/navigation-cube/components/cube-scene.d.ts +13 -0
  32. package/dist/gui/navigation-cube/components/cube-scene.js +546 -0
  33. package/dist/gui/navigation-cube/components/cube-scene.js.map +1 -0
  34. package/dist/gui/navigation-cube/components/cube.mouse.d.ts +9 -0
  35. package/dist/gui/navigation-cube/components/cube.mouse.js +109 -0
  36. package/dist/gui/navigation-cube/components/cube.mouse.js.map +1 -0
  37. package/dist/gui/navigation-cube/viral-navigation-cube.d.ts +16 -0
  38. package/dist/gui/navigation-cube/viral-navigation-cube.js +50 -0
  39. package/dist/gui/navigation-cube/viral-navigation-cube.js.map +1 -0
  40. package/dist/gui/spinner/viral-spinner.d.ts +10 -0
  41. package/dist/gui/spinner/viral-spinner.js +102 -0
  42. package/dist/gui/spinner/viral-spinner.js.map +1 -0
  43. package/dist/gui/tools/tools/viral-tool-ambient-occlusion.d.ts +7 -0
  44. package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js +16 -0
  45. package/dist/gui/tools/tools/viral-tool-ambient-occlusion.js.map +1 -0
  46. package/dist/gui/tools/tools/viral-tool-dark-mode.d.ts +7 -0
  47. package/dist/gui/tools/tools/viral-tool-dark-mode.js +21 -0
  48. package/dist/gui/tools/tools/viral-tool-dark-mode.js.map +1 -0
  49. package/dist/gui/tools/tools/viral-tool-elevation.d.ts +11 -0
  50. package/dist/gui/tools/tools/viral-tool-elevation.js +30 -0
  51. package/dist/gui/tools/tools/viral-tool-elevation.js.map +1 -0
  52. package/dist/gui/tools/tools/viral-tool-measure.d.ts +33 -0
  53. package/dist/gui/tools/tools/viral-tool-measure.js +243 -0
  54. package/dist/gui/tools/tools/viral-tool-measure.js.map +1 -0
  55. package/dist/gui/tools/tools/viral-tool-sunlight.d.ts +7 -0
  56. package/dist/gui/tools/tools/viral-tool-sunlight.js +46 -0
  57. package/dist/gui/tools/tools/viral-tool-sunlight.js.map +1 -0
  58. package/dist/gui/tools/viral-tools.d.ts +32 -0
  59. package/dist/gui/tools/viral-tools.js +213 -0
  60. package/dist/gui/tools/viral-tools.js.map +1 -0
  61. package/dist/models/dictionary.model.d.ts +0 -10
  62. package/dist/models/dictionary.model.js +0 -41
  63. package/dist/models/dictionary.model.js.map +1 -1
  64. package/dist/threejs-addon/gltf-loader.d.ts +1 -1
  65. package/dist/threejs-addon/n8ao/n8ao.d.ts +8 -8
  66. package/dist/threejs-addon/n8ao/post-processing.d.ts +3919 -1534
  67. package/dist/threejs-addon/post-processing/outline-pass.d.ts +7 -7
  68. package/dist/threejs-addon/post-processing/pass.d.ts +1 -1
  69. package/dist/threejs-addon/post-processing/sao-pass.d.ts +5 -5
  70. package/dist/threejs-addon/post-processing/ssaa-render-pass.d.ts +30 -0
  71. package/dist/threejs-addon/post-processing/ssaa-render-pass.js +202 -0
  72. package/dist/threejs-addon/post-processing/ssaa-render-pass.js.map +1 -0
  73. package/dist/threejs-addon/post-processing/unreal-bloom-pass.d.ts +3 -3
  74. package/dist/threejs-addon/shaders/color-correction-shader.d.ts +22 -0
  75. package/dist/threejs-addon/shaders/color-correction-shader.js +43 -0
  76. package/dist/threejs-addon/shaders/color-correction-shader.js.map +1 -0
  77. package/dist/threejs-addon/shaders/fxaa-shader.d.ts +14 -0
  78. package/dist/threejs-addon/shaders/fxaa-shader.js +279 -0
  79. package/dist/threejs-addon/shaders/fxaa-shader.js.map +1 -0
  80. package/dist/threejs-addon/transform-control.d.ts +3 -3
  81. package/dist/viral-viewer-api.d.ts +8 -6
  82. package/dist/viral-viewer-api.js +8 -6
  83. package/dist/viral-viewer-api.js.map +1 -1
  84. package/package.json +5 -2
  85. package/dist/components/compress/compress.processor.d.ts +0 -4
  86. package/dist/components/compress/compress.processor.js +0 -29
  87. package/dist/components/compress/compress.processor.js.map +0 -1
  88. package/dist/components/loader/viral-viewer-point-cloud.loader.d.ts +0 -16
  89. package/dist/components/loader/viral-viewer-point-cloud.loader.js +0 -33
  90. package/dist/components/loader/viral-viewer-point-cloud.loader.js.map +0 -1
  91. package/dist/components/loader/viral-viewer-revit.loader.d.ts +0 -13
  92. package/dist/components/loader/viral-viewer-revit.loader.js +0 -124
  93. package/dist/components/loader/viral-viewer-revit.loader.js.map +0 -1
  94. package/dist/components/worker/load-model.d.ts +0 -126
  95. package/dist/components/worker/load-model.js +0 -1265
  96. package/dist/components/worker/load-model.js.map +0 -1
  97. package/dist/components/worker/test-worker-pool.d.ts +0 -6
  98. package/dist/components/worker/test-worker-pool.js +0 -21
  99. package/dist/components/worker/test-worker-pool.js.map +0 -1
  100. package/dist/components/worker/viral-viewer.worker-pool.d.ts +0 -0
  101. package/dist/components/worker/viral-viewer.worker-pool.js +0 -61
  102. package/dist/components/worker/viral-viewer.worker-pool.js.map +0 -1
  103. package/dist/components/worker/worker-pool.d.ts +0 -21
  104. package/dist/components/worker/worker-pool.js +0 -47
  105. package/dist/components/worker/worker-pool.js.map +0 -1
  106. package/dist/components/worker/worker-thread.d.ts +0 -9
  107. package/dist/components/worker/worker-thread.js +0 -30
  108. package/dist/components/worker/worker-thread.js.map +0 -1
  109. package/dist/components/worker-script/test-worker-pool.script.d.ts +0 -1
  110. package/dist/components/worker-script/test-worker-pool.script.js +0 -12
  111. package/dist/components/worker-script/test-worker-pool.script.js.map +0 -1
@@ -13,16 +13,16 @@ export class OutlinePass extends Pass {
13
13
  pulsePeriod: number;
14
14
  _visibilityCache: Map<any, any>;
15
15
  resolution: Vector2;
16
- renderTargetMaskBuffer: WebGLRenderTarget;
16
+ renderTargetMaskBuffer: WebGLRenderTarget<import("three").Texture>;
17
17
  depthMaterial: MeshDepthMaterial;
18
18
  prepareMaskMaterial: ShaderMaterial;
19
- renderTargetDepthBuffer: WebGLRenderTarget;
20
- renderTargetMaskDownSampleBuffer: WebGLRenderTarget;
21
- renderTargetBlurBuffer1: WebGLRenderTarget;
22
- renderTargetBlurBuffer2: WebGLRenderTarget;
19
+ renderTargetDepthBuffer: WebGLRenderTarget<import("three").Texture>;
20
+ renderTargetMaskDownSampleBuffer: WebGLRenderTarget<import("three").Texture>;
21
+ renderTargetBlurBuffer1: WebGLRenderTarget<import("three").Texture>;
22
+ renderTargetBlurBuffer2: WebGLRenderTarget<import("three").Texture>;
23
23
  edgeDetectionMaterial: ShaderMaterial;
24
- renderTargetEdgeBuffer1: WebGLRenderTarget;
25
- renderTargetEdgeBuffer2: WebGLRenderTarget;
24
+ renderTargetEdgeBuffer1: WebGLRenderTarget<import("three").Texture>;
25
+ renderTargetEdgeBuffer2: WebGLRenderTarget<import("three").Texture>;
26
26
  separableBlurMaterial1: ShaderMaterial;
27
27
  separableBlurMaterial2: ShaderMaterial;
28
28
  overlayMaterial: ShaderMaterial;
@@ -10,7 +10,7 @@ export class Pass {
10
10
  }
11
11
  export class FullScreenQuad {
12
12
  constructor(material: any);
13
- _mesh: Mesh<BufferGeometry<import("three").NormalBufferAttributes>, any>;
13
+ _mesh: Mesh<BufferGeometry<import("three").NormalBufferAttributes>, any, import("three").Object3DEventMap>;
14
14
  dispose(): void;
15
15
  render(renderer: any): void;
16
16
  set material(arg: any);
@@ -23,11 +23,11 @@ export class SAOPass extends Pass {
23
23
  saoBlurDepthCutoff: number;
24
24
  };
25
25
  resolution: Vector2;
26
- saoRenderTarget: WebGLRenderTarget;
27
- blurIntermediateRenderTarget: WebGLRenderTarget;
28
- beautyRenderTarget: WebGLRenderTarget;
29
- normalRenderTarget: WebGLRenderTarget;
30
- depthRenderTarget: WebGLRenderTarget;
26
+ saoRenderTarget: WebGLRenderTarget<import("three").Texture>;
27
+ blurIntermediateRenderTarget: WebGLRenderTarget<import("three").Texture>;
28
+ beautyRenderTarget: WebGLRenderTarget<import("three").Texture>;
29
+ normalRenderTarget: WebGLRenderTarget<import("three").Texture>;
30
+ depthRenderTarget: WebGLRenderTarget<import("three").Texture>;
31
31
  depthMaterial: MeshDepthMaterial;
32
32
  normalMaterial: MeshNormalMaterial;
33
33
  saoMaterial: ShaderMaterial;
@@ -0,0 +1,30 @@
1
+ /**
2
+ *
3
+ * Supersample Anti-Aliasing Render Pass
4
+ *
5
+ * This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
6
+ *
7
+ * References: https://en.wikipedia.org/wiki/Supersampling
8
+ *
9
+ */
10
+ export class SSAARenderPass extends Pass {
11
+ constructor(scene: any, camera: any, clearColor: any, clearAlpha: any);
12
+ scene: any;
13
+ camera: any;
14
+ sampleLevel: number;
15
+ unbiased: boolean;
16
+ clearColor: any;
17
+ clearAlpha: any;
18
+ _oldClearColor: Color;
19
+ copyUniforms: any;
20
+ copyMaterial: ShaderMaterial;
21
+ fsQuad: FullScreenQuad;
22
+ sampleRenderTarget: WebGLRenderTarget<import("three").Texture> | null | undefined;
23
+ setSize(width: any, height: any): void;
24
+ render(renderer: any, writeBuffer: any, readBuffer: any): void;
25
+ }
26
+ import { Pass } from './pass';
27
+ import { Color } from 'three';
28
+ import { ShaderMaterial } from 'three';
29
+ import { FullScreenQuad } from './pass';
30
+ import { WebGLRenderTarget } from 'three';
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SSAARenderPass = void 0;
4
+ const three_1 = require("three");
5
+ const pass_1 = require("./pass");
6
+ const copy_shader_1 = require("../shaders/copy-shader");
7
+ /**
8
+ *
9
+ * Supersample Anti-Aliasing Render Pass
10
+ *
11
+ * This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
12
+ *
13
+ * References: https://en.wikipedia.org/wiki/Supersampling
14
+ *
15
+ */
16
+ class SSAARenderPass extends pass_1.Pass {
17
+ constructor(scene, camera, clearColor, clearAlpha) {
18
+ super();
19
+ this.scene = scene;
20
+ this.camera = camera;
21
+ this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
22
+ this.unbiased = true;
23
+ // as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
24
+ this.clearColor = (clearColor !== undefined) ? clearColor : 0x000000;
25
+ this.clearAlpha = (clearAlpha !== undefined) ? clearAlpha : 0;
26
+ this._oldClearColor = new three_1.Color();
27
+ const copyShader = copy_shader_1.CopyShader;
28
+ this.copyUniforms = three_1.UniformsUtils.clone(copyShader.uniforms);
29
+ this.copyMaterial = new three_1.ShaderMaterial({
30
+ uniforms: this.copyUniforms,
31
+ vertexShader: copyShader.vertexShader,
32
+ fragmentShader: copyShader.fragmentShader,
33
+ transparent: true,
34
+ depthTest: false,
35
+ depthWrite: false,
36
+ // do not use AdditiveBlending because it mixes the alpha channel instead of adding
37
+ blending: three_1.CustomBlending,
38
+ blendEquation: three_1.AddEquation,
39
+ blendDst: three_1.OneFactor,
40
+ blendDstAlpha: three_1.OneFactor,
41
+ blendSrc: three_1.SrcAlphaFactor,
42
+ blendSrcAlpha: three_1.OneFactor
43
+ });
44
+ this.fsQuad = new pass_1.FullScreenQuad(this.copyMaterial);
45
+ }
46
+ dispose() {
47
+ if (this.sampleRenderTarget) {
48
+ this.sampleRenderTarget.dispose();
49
+ this.sampleRenderTarget = null;
50
+ }
51
+ this.copyMaterial.dispose();
52
+ this.fsQuad.dispose();
53
+ }
54
+ setSize(width, height) {
55
+ if (this.sampleRenderTarget)
56
+ this.sampleRenderTarget.setSize(width, height);
57
+ }
58
+ render(renderer, writeBuffer, readBuffer) {
59
+ if (!this.sampleRenderTarget) {
60
+ this.sampleRenderTarget = new three_1.WebGLRenderTarget(readBuffer.width, readBuffer.height);
61
+ this.sampleRenderTarget.texture.name = 'SSAARenderPass.sample';
62
+ }
63
+ const jitterOffsets = _JitterVectors[Math.max(0, Math.min(this.sampleLevel, 5))];
64
+ const autoClear = renderer.autoClear;
65
+ renderer.autoClear = false;
66
+ renderer.getClearColor(this._oldClearColor);
67
+ const oldClearAlpha = renderer.getClearAlpha();
68
+ const baseSampleWeight = 1.0 / jitterOffsets.length;
69
+ const roundingRange = 1 / 32;
70
+ this.copyUniforms['tDiffuse'].value = this.sampleRenderTarget.texture;
71
+ const viewOffset = {
72
+ fullWidth: readBuffer.width,
73
+ fullHeight: readBuffer.height,
74
+ offsetX: 0,
75
+ offsetY: 0,
76
+ width: readBuffer.width,
77
+ height: readBuffer.height
78
+ };
79
+ const originalViewOffset = Object.assign({}, this.camera.view);
80
+ if (originalViewOffset.enabled)
81
+ Object.assign(viewOffset, originalViewOffset);
82
+ // render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
83
+ for (let i = 0; i < jitterOffsets.length; i++) {
84
+ const jitterOffset = jitterOffsets[i];
85
+ if (this.camera.setViewOffset) {
86
+ this.camera.setViewOffset(viewOffset.fullWidth, viewOffset.fullHeight, viewOffset.offsetX + jitterOffset[0] * 0.0625, viewOffset.offsetY + jitterOffset[1] * 0.0625, // 0.0625 = 1 / 16
87
+ viewOffset.width, viewOffset.height);
88
+ }
89
+ let sampleWeight = baseSampleWeight;
90
+ if (this.unbiased) {
91
+ // the theory is that equal weights for each sample lead to an accumulation of rounding errors.
92
+ // The following equation varies the sampleWeight per sample so that it is uniformly distributed
93
+ // across a range of values whose rounding errors cancel each other out.
94
+ const uniformCenteredDistribution = (-0.5 + (i + 0.5) / jitterOffsets.length);
95
+ sampleWeight += roundingRange * uniformCenteredDistribution;
96
+ }
97
+ this.copyUniforms['opacity'].value = sampleWeight;
98
+ renderer.setClearColor(this.clearColor, this.clearAlpha);
99
+ renderer.setRenderTarget(this.sampleRenderTarget);
100
+ renderer.clear();
101
+ renderer.render(this.scene, this.camera);
102
+ renderer.setRenderTarget(this.renderToScreen ? null : writeBuffer);
103
+ if (i === 0) {
104
+ renderer.setClearColor(0x000000, 0.0);
105
+ renderer.clear();
106
+ }
107
+ this.fsQuad.render(renderer);
108
+ }
109
+ if (this.camera.setViewOffset && originalViewOffset.enabled) {
110
+ this.camera.setViewOffset(originalViewOffset.fullWidth, originalViewOffset.fullHeight, originalViewOffset.offsetX, originalViewOffset.offsetY, originalViewOffset.width, originalViewOffset.height);
111
+ }
112
+ else if (this.camera.clearViewOffset) {
113
+ this.camera.clearViewOffset();
114
+ }
115
+ renderer.autoClear = autoClear;
116
+ renderer.setClearColor(this._oldClearColor, oldClearAlpha);
117
+ }
118
+ }
119
+ exports.SSAARenderPass = SSAARenderPass;
120
+ // These jitter vectors are specified in integers because it is easier.
121
+ // I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
122
+ // before being used, thus these integers need to be scaled by 1/16.
123
+ //
124
+ // Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
125
+ const _JitterVectors = [
126
+ [
127
+ [0, 0]
128
+ ],
129
+ [
130
+ [4, 4],
131
+ [-4, -4]
132
+ ],
133
+ [
134
+ [-2, -6],
135
+ [6, -2],
136
+ [-6, 2],
137
+ [2, 6]
138
+ ],
139
+ [
140
+ [1, -3],
141
+ [-1, 3],
142
+ [5, 1],
143
+ [-3, -5],
144
+ [-5, 5],
145
+ [-7, -1],
146
+ [3, 7],
147
+ [7, -7]
148
+ ],
149
+ [
150
+ [1, 1],
151
+ [-1, -3],
152
+ [-3, 2],
153
+ [4, -1],
154
+ [-5, -2],
155
+ [2, 5],
156
+ [5, 3],
157
+ [3, -5],
158
+ [-2, 6],
159
+ [0, -7],
160
+ [-4, -6],
161
+ [-6, 4],
162
+ [-8, 0],
163
+ [7, -4],
164
+ [6, 7],
165
+ [-7, -8]
166
+ ],
167
+ [
168
+ [-4, -7],
169
+ [-7, -5],
170
+ [-3, -5],
171
+ [-5, -4],
172
+ [-1, -4],
173
+ [-2, -2],
174
+ [-6, -1],
175
+ [-4, 0],
176
+ [-7, 1],
177
+ [-1, 2],
178
+ [-6, 3],
179
+ [-3, 3],
180
+ [-7, 6],
181
+ [-3, 6],
182
+ [-5, 7],
183
+ [-1, 7],
184
+ [5, -7],
185
+ [1, -6],
186
+ [6, -5],
187
+ [4, -4],
188
+ [2, -3],
189
+ [7, -2],
190
+ [1, -1],
191
+ [4, -1],
192
+ [2, 1],
193
+ [6, 2],
194
+ [0, 4],
195
+ [4, 4],
196
+ [2, 5],
197
+ [7, 5],
198
+ [5, 6],
199
+ [3, 7]
200
+ ]
201
+ ];
202
+ //# sourceMappingURL=ssaa-render-pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssaa-render-pass.js","sourceRoot":"","sources":["../../../src/threejs-addon/post-processing/ssaa-render-pass.js"],"names":[],"mappings":";;;AAAA,iCASe;AACf,iCAA8C;AAC9C,wDAAoD;AAEpD;;;;;;;;GAQG;AAEH,MAAM,cAAe,SAAQ,WAAI;IAE7B,YAAY,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;QAE7C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,8FAA8F;QACpH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,uGAAuG;QACvG,IAAI,CAAC,UAAU,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrE,IAAI,CAAC,UAAU,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,cAAc,GAAG,IAAI,aAAK,EAAE,CAAC;QAElC,MAAM,UAAU,GAAG,wBAAU,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,qBAAa,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAE7D,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAc,CAAC;YACnC,QAAQ,EAAE,IAAI,CAAC,YAAY;YAC3B,YAAY,EAAE,UAAU,CAAC,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ACP,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACP,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;QACN,CAAC,CAAC,EAAE,CAAC,CAAC;KACT;CACJ,CAAC"}
@@ -14,10 +14,10 @@ export class UnrealBloomPass extends Pass {
14
14
  threshold: any;
15
15
  resolution: Vector2;
16
16
  clearColor: Color;
17
- renderTargetsHorizontal: WebGLRenderTarget[];
18
- renderTargetsVertical: WebGLRenderTarget[];
17
+ renderTargetsHorizontal: WebGLRenderTarget<import("three").Texture>[];
18
+ renderTargetsVertical: WebGLRenderTarget<import("three").Texture>[];
19
19
  nMips: number;
20
- renderTargetBright: WebGLRenderTarget;
20
+ renderTargetBright: WebGLRenderTarget<import("three").Texture>;
21
21
  highPassUniforms: any;
22
22
  materialHighPassFilter: ShaderMaterial;
23
23
  separableBlurMaterials: ShaderMaterial[];
@@ -0,0 +1,22 @@
1
+ export namespace ColorCorrectionShader {
2
+ namespace uniforms {
3
+ namespace tDiffuse {
4
+ const value: null;
5
+ }
6
+ namespace powRGB {
7
+ const value_1: Vector3;
8
+ export { value_1 as value };
9
+ }
10
+ namespace mulRGB {
11
+ const value_2: Vector3;
12
+ export { value_2 as value };
13
+ }
14
+ namespace addRGB {
15
+ const value_3: Vector3;
16
+ export { value_3 as value };
17
+ }
18
+ }
19
+ const vertexShader: string;
20
+ const fragmentShader: string;
21
+ }
22
+ import { Vector3 } from 'three';
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorCorrectionShader = void 0;
4
+ const three_1 = require("three");
5
+ /**
6
+ * Color correction
7
+ */
8
+ const ColorCorrectionShader = {
9
+ uniforms: {
10
+ 'tDiffuse': { value: null },
11
+ 'powRGB': { value: new three_1.Vector3(2, 2, 2) },
12
+ 'mulRGB': { value: new three_1.Vector3(1, 1, 1) },
13
+ 'addRGB': { value: new three_1.Vector3(0, 0, 0) }
14
+ },
15
+ vertexShader: /* glsl */ `
16
+
17
+ varying vec2 vUv;
18
+
19
+ void main() {
20
+
21
+ vUv = uv;
22
+
23
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
24
+
25
+ }`,
26
+ fragmentShader: /* glsl */ `
27
+
28
+ uniform sampler2D tDiffuse;
29
+ uniform vec3 powRGB;
30
+ uniform vec3 mulRGB;
31
+ uniform vec3 addRGB;
32
+
33
+ varying vec2 vUv;
34
+
35
+ void main() {
36
+
37
+ gl_FragColor = texture2D( tDiffuse, vUv );
38
+ gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );
39
+
40
+ }`
41
+ };
42
+ exports.ColorCorrectionShader = ColorCorrectionShader;
43
+ //# sourceMappingURL=color-correction-shader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-correction-shader.js","sourceRoot":"","sources":["../../../src/threejs-addon/shaders/color-correction-shader.js"],"names":[],"mappings":";;;AAAA,iCAEe;AAEf;;GAEG;AAEH,MAAM,qBAAqB,GAAG;IAE1B,QAAQ,EAAE;QAEN,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;QAC3B,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;QACzC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;QACzC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;KAE5C;IAED,YAAY,EAAE,UAAU,CAAC;;;;;;;;;;IAUzB;IAEA,cAAc,EAAE,UAAU,CAAC;;;;;;;;;;;;;;IAc3B;CAEH,CAAC;AAEO,sDAAqB"}
@@ -0,0 +1,14 @@
1
+ export namespace FXAAShader {
2
+ namespace uniforms {
3
+ namespace tDiffuse {
4
+ const value: null;
5
+ }
6
+ namespace resolution {
7
+ const value_1: Vector2;
8
+ export { value_1 as value };
9
+ }
10
+ }
11
+ const vertexShader: string;
12
+ const fragmentShader: string;
13
+ }
14
+ import { Vector2 } from 'three';
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FXAAShader = void 0;
4
+ const three_1 = require("three");
5
+ /**
6
+ * NVIDIA FXAA by Timothy Lottes
7
+ * https://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
8
+ * - WebGL port by @supereggbert
9
+ * http://www.glge.org/demos/fxaa/
10
+ * Further improved by Daniel Sturk
11
+ */
12
+ const FXAAShader = {
13
+ uniforms: {
14
+ 'tDiffuse': { value: null },
15
+ 'resolution': { value: new three_1.Vector2(1 / 1024, 1 / 512) }
16
+ },
17
+ vertexShader: /* glsl */ `
18
+
19
+ varying vec2 vUv;
20
+
21
+ void main() {
22
+
23
+ vUv = uv;
24
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
25
+
26
+ }`,
27
+ fragmentShader: `
28
+ precision highp float;
29
+
30
+ uniform sampler2D tDiffuse;
31
+
32
+ uniform vec2 resolution;
33
+
34
+ varying vec2 vUv;
35
+
36
+ // FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)
37
+
38
+ //----------------------------------------------------------------------------------
39
+ // File: es3-kepler\FXAA\assets\shaders/FXAA_DefaultES.frag
40
+ // SDK Version: v3.00
41
+ // Email: gameworks@nvidia.com
42
+ // Site: http://developer.nvidia.com/
43
+ //
44
+ // Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
45
+ //
46
+ // Redistribution and use in source and binary forms, with or without
47
+ // modification, are permitted provided that the following conditions
48
+ // are met:
49
+ // * Redistributions of source code must retain the above copyright
50
+ // notice, this list of conditions and the following disclaimer.
51
+ // * Redistributions in binary form must reproduce the above copyright
52
+ // notice, this list of conditions and the following disclaimer in the
53
+ // documentation and/or other materials provided with the distribution.
54
+ // * Neither the name of NVIDIA CORPORATION nor the names of its
55
+ // contributors may be used to endorse or promote products derived
56
+ // from this software without specific prior written permission.
57
+ //
58
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
59
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61
+ // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
62
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
63
+ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
64
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
65
+ // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
66
+ // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69
+ //
70
+ //----------------------------------------------------------------------------------
71
+
72
+ #ifndef FXAA_DISCARD
73
+ //
74
+ // Only valid for PC OpenGL currently.
75
+ // Probably will not work when FXAA_GREEN_AS_LUMA = 1.
76
+ //
77
+ // 1 = Use discard on pixels which don't need AA.
78
+ // For APIs which enable concurrent TEX+ROP from same surface.
79
+ // 0 = Return unchanged color on pixels which don't need AA.
80
+ //
81
+ #define FXAA_DISCARD 0
82
+ #endif
83
+
84
+ /*--------------------------------------------------------------------------*/
85
+ #define FxaaTexTop(t, p) texture2D(t, p, -100.0)
86
+ #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)
87
+ /*--------------------------------------------------------------------------*/
88
+
89
+ #define NUM_SAMPLES 5
90
+
91
+ // assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha
92
+ float contrast( vec4 a, vec4 b ) {
93
+ vec4 diff = abs( a - b );
94
+ return max( max( max( diff.r, diff.g ), diff.b ), diff.a );
95
+ }
96
+
97
+ /*============================================================================
98
+
99
+ FXAA3 QUALITY - PC
100
+
101
+ ============================================================================*/
102
+
103
+ /*--------------------------------------------------------------------------*/
104
+ vec4 FxaaPixelShader(
105
+ vec2 posM,
106
+ sampler2D tex,
107
+ vec2 fxaaQualityRcpFrame,
108
+ float fxaaQualityEdgeThreshold,
109
+ float fxaaQualityinvEdgeThreshold
110
+ ) {
111
+ vec4 rgbaM = FxaaTexTop(tex, posM);
112
+ vec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);
113
+ vec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);
114
+ vec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);
115
+ vec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);
116
+ // . S .
117
+ // W M E
118
+ // . N .
119
+
120
+ bool earlyExit = max( max( max(
121
+ contrast( rgbaM, rgbaN ),
122
+ contrast( rgbaM, rgbaS ) ),
123
+ contrast( rgbaM, rgbaE ) ),
124
+ contrast( rgbaM, rgbaW ) )
125
+ < fxaaQualityEdgeThreshold;
126
+ // . 0 .
127
+ // 0 0 0
128
+ // . 0 .
129
+
130
+ #if (FXAA_DISCARD == 1)
131
+ if(earlyExit) FxaaDiscard;
132
+ #else
133
+ if(earlyExit) return rgbaM;
134
+ #endif
135
+
136
+ float contrastN = contrast( rgbaM, rgbaN );
137
+ float contrastS = contrast( rgbaM, rgbaS );
138
+ float contrastE = contrast( rgbaM, rgbaE );
139
+ float contrastW = contrast( rgbaM, rgbaW );
140
+
141
+ float relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );
142
+ relativeVContrast *= fxaaQualityinvEdgeThreshold;
143
+
144
+ bool horzSpan = relativeVContrast > 0.;
145
+ // . 1 .
146
+ // 0 0 0
147
+ // . 1 .
148
+
149
+ // 45 deg edge detection and corners of objects, aka V/H contrast is too similar
150
+ if( abs( relativeVContrast ) < .3 ) {
151
+ // locate the edge
152
+ vec2 dirToEdge;
153
+ dirToEdge.x = contrastE > contrastW ? 1. : -1.;
154
+ dirToEdge.y = contrastS > contrastN ? 1. : -1.;
155
+ // . 2 . . 1 .
156
+ // 1 0 2 ~= 0 0 1
157
+ // . 1 . . 0 .
158
+
159
+ // tap 2 pixels and see which ones are "outside" the edge, to
160
+ // determine if the edge is vertical or horizontal
161
+
162
+ vec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);
163
+ float matchAlongH = contrast( rgbaM, rgbaAlongH );
164
+ // . 1 .
165
+ // 0 0 1
166
+ // . 0 H
167
+
168
+ vec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);
169
+ float matchAlongV = contrast( rgbaM, rgbaAlongV );
170
+ // V 1 .
171
+ // 0 0 1
172
+ // . 0 .
173
+
174
+ relativeVContrast = matchAlongV - matchAlongH;
175
+ relativeVContrast *= fxaaQualityinvEdgeThreshold;
176
+
177
+ if( abs( relativeVContrast ) < .3 ) { // 45 deg edge
178
+ // 1 1 .
179
+ // 0 0 1
180
+ // . 0 1
181
+
182
+ // do a simple blur
183
+ return mix(
184
+ rgbaM,
185
+ (rgbaN + rgbaS + rgbaE + rgbaW) * .25,
186
+ .4
187
+ );
188
+ }
189
+
190
+ horzSpan = relativeVContrast > 0.;
191
+ }
192
+
193
+ if(!horzSpan) rgbaN = rgbaW;
194
+ if(!horzSpan) rgbaS = rgbaE;
195
+ // . 0 . 1
196
+ // 1 0 1 -> 0
197
+ // . 0 . 1
198
+
199
+ bool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );
200
+ if(!pairN) rgbaN = rgbaS;
201
+
202
+ vec2 offNP;
203
+ offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
204
+ offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
205
+
206
+ bool doneN = false;
207
+ bool doneP = false;
208
+
209
+ float nDist = 0.;
210
+ float pDist = 0.;
211
+
212
+ vec2 posN = posM;
213
+ vec2 posP = posM;
214
+
215
+ int iterationsUsed = 0;
216
+ int iterationsUsedN = 0;
217
+ int iterationsUsedP = 0;
218
+ for( int i = 0; i < NUM_SAMPLES; i++ ) {
219
+ iterationsUsed = i;
220
+
221
+ float increment = float(i + 1);
222
+
223
+ if(!doneN) {
224
+ nDist += increment;
225
+ posN = posM + offNP * nDist;
226
+ vec4 rgbaEndN = FxaaTexTop(tex, posN.xy);
227
+ doneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );
228
+ iterationsUsedN = i;
229
+ }
230
+
231
+ if(!doneP) {
232
+ pDist += increment;
233
+ posP = posM - offNP * pDist;
234
+ vec4 rgbaEndP = FxaaTexTop(tex, posP.xy);
235
+ doneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );
236
+ iterationsUsedP = i;
237
+ }
238
+
239
+ if(doneN || doneP) break;
240
+ }
241
+
242
+
243
+ if ( !doneP && !doneN ) return rgbaM; // failed to find end of edge
244
+
245
+ float dist = min(
246
+ doneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,
247
+ doneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.
248
+ );
249
+
250
+ // hacky way of reduces blurriness of mostly diagonal edges
251
+ // but reduces AA quality
252
+ dist = pow(dist, .5);
253
+
254
+ dist = 1. - dist;
255
+
256
+ return mix(
257
+ rgbaM,
258
+ rgbaN,
259
+ dist * .5
260
+ );
261
+ }
262
+
263
+ void main() {
264
+ const float edgeDetectionQuality = .2;
265
+ const float invEdgeDetectionQuality = 1. / edgeDetectionQuality;
266
+
267
+ gl_FragColor = FxaaPixelShader(
268
+ vUv,
269
+ tDiffuse,
270
+ resolution,
271
+ edgeDetectionQuality, // [0,1] contrast needed, otherwise early discard
272
+ invEdgeDetectionQuality
273
+ );
274
+
275
+ }
276
+ `
277
+ };
278
+ exports.FXAAShader = FXAAShader;
279
+ //# sourceMappingURL=fxaa-shader.js.map