viral-viewer-2 3.5.2 → 3.5.3

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.
@@ -8,7 +8,7 @@ class ViralAnimation {
8
8
  this.clock = new three_1.Clock();
9
9
  }
10
10
  devAnimation() {
11
- var _a, _b, _c, _d, _e;
11
+ var _a, _b, _c, _d, _e, _f;
12
12
  const delta = this.clock.getDelta();
13
13
  const elapsed = this.clock.getElapsedTime();
14
14
  const updated1 = (_a = this.viralViewerApi.viralCamera.cameraControls) === null || _a === void 0 ? void 0 : _a.update(delta);
@@ -17,23 +17,24 @@ class ViralAnimation {
17
17
  }
18
18
  requestAnimationFrame(() => { this.devAnimation(); });
19
19
  if (updated1) {
20
- this.viralViewerApi.viralRenderer.render();
20
+ // this.viralViewerApi.viralRenderer.render();
21
21
  // this.viralViewerApi.viralPostProcessing.composer?.render();
22
+ (_b = this.viralViewerApi.outlineEffect.composer) === null || _b === void 0 ? void 0 : _b.render();
22
23
  if (this.viralViewerApi.viralNavigationCube.cubeCamera) {
23
24
  this.viralViewerApi.viralNavigationCube.cubeCamera.updateCubeCamera();
24
25
  }
25
26
  }
26
27
  if (this.viralViewerApi.viralNavigationCube.cubeCamera && this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) {
27
- const updated2 = (_b = this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) === null || _b === void 0 ? void 0 : _b.update(delta);
28
+ const updated2 = (_c = this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) === null || _c === void 0 ? void 0 : _c.update(delta);
28
29
  if (updated2) {
29
- (_c = this.viralViewerApi.viralNavigationCube.cubeRenderer) === null || _c === void 0 ? void 0 : _c.render();
30
+ (_d = this.viralViewerApi.viralNavigationCube.cubeRenderer) === null || _d === void 0 ? void 0 : _d.render();
30
31
  // this.viralViewerApi.viralCamera.updateMainCamera();
31
32
  }
32
33
  }
33
- (_e = (_d = this.viralViewerApi.viralStats) === null || _d === void 0 ? void 0 : _d.stats) === null || _e === void 0 ? void 0 : _e.update();
34
+ (_f = (_e = this.viralViewerApi.viralStats) === null || _e === void 0 ? void 0 : _e.stats) === null || _f === void 0 ? void 0 : _f.update();
34
35
  }
35
36
  animation() {
36
- var _a, _b, _c;
37
+ var _a, _b, _c, _d;
37
38
  const delta = this.clock.getDelta();
38
39
  const elapsed = this.clock.getElapsedTime();
39
40
  const updated1 = (_a = this.viralViewerApi.viralCamera.cameraControls) === null || _a === void 0 ? void 0 : _a.update(delta);
@@ -43,15 +44,16 @@ class ViralAnimation {
43
44
  requestAnimationFrame(() => { this.animation(); });
44
45
  if (updated1) {
45
46
  // this.viralViewerApi.viralPostProcessing.composer?.render();
46
- this.viralViewerApi.viralRenderer.render();
47
+ // this.viralViewerApi.viralRenderer.render();
48
+ (_b = this.viralViewerApi.outlineEffect.composer) === null || _b === void 0 ? void 0 : _b.render();
47
49
  if (this.viralViewerApi.viralNavigationCube.cubeCamera) {
48
50
  this.viralViewerApi.viralNavigationCube.cubeCamera.updateCubeCamera();
49
51
  }
50
52
  }
51
53
  if (this.viralViewerApi.viralNavigationCube.cubeCamera && this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) {
52
- const updated2 = (_b = this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) === null || _b === void 0 ? void 0 : _b.update(delta);
54
+ const updated2 = (_c = this.viralViewerApi.viralNavigationCube.cubeCamera.cameraControls) === null || _c === void 0 ? void 0 : _c.update(delta);
53
55
  if (updated2) {
54
- (_c = this.viralViewerApi.viralNavigationCube.cubeRenderer) === null || _c === void 0 ? void 0 : _c.render();
56
+ (_d = this.viralViewerApi.viralNavigationCube.cubeRenderer) === null || _d === void 0 ? void 0 : _d.render();
55
57
  // this.viralViewerApi.viralCamera.updateMainCamera();
56
58
  }
57
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"viral-animation.js","sourceRoot":"","sources":["../../../src/components/animation/viral-animation.ts"],"names":[],"mappings":";;;AAAA,iCAA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c,CAAC,mBAAmB,CAAC,YAAY,0CAAE,MAAM,EAAE,CAAC;gBAC/D,sDAAsD;aACzD;SACJ;IAEL,CAAC;CAEJ;AAvED,wCAuEC"}
@@ -0,0 +1,15 @@
1
+ import { EffectComposer } from "../../threejs-addon/post-processing/effect-composer";
2
+ import { OutlinePass } from "../../threejs-addon/post-processing/outline-pass";
3
+ import { RenderPass } from "../../threejs-addon/post-processing/render-pass";
4
+ import { ViralViewerApi } from "../../viral-viewer-api";
5
+ import { OutputPass } from "../../threejs-addon/post-processing/output-pass";
6
+ import { ShaderPass } from "../../threejs-addon/post-processing/shader-pass";
7
+ export declare class OutlineEffect {
8
+ private viralViewerApi;
9
+ composer: EffectComposer | null;
10
+ renderPass: RenderPass | null;
11
+ outlinePass: OutlinePass | null;
12
+ outputPass: OutputPass | null;
13
+ shaderPass: ShaderPass | null;
14
+ constructor(viralViewerApi: ViralViewerApi);
15
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutlineEffect = void 0;
4
+ const three_1 = require("three");
5
+ const effect_composer_1 = require("../../threejs-addon/post-processing/effect-composer");
6
+ const outline_pass_1 = require("../../threejs-addon/post-processing/outline-pass");
7
+ const render_pass_1 = require("../../threejs-addon/post-processing/render-pass");
8
+ const output_pass_1 = require("../../threejs-addon/post-processing/output-pass");
9
+ const shader_pass_1 = require("../../threejs-addon/post-processing/shader-pass");
10
+ const fxaa_shader_1 = require("../../threejs-addon/shaders/fxaa-shader");
11
+ class OutlineEffect {
12
+ constructor(viralViewerApi) {
13
+ this.viralViewerApi = viralViewerApi;
14
+ this.composer = null;
15
+ //effect
16
+ this.renderPass = null;
17
+ this.outlinePass = null;
18
+ this.outputPass = null;
19
+ this.shaderPass = null;
20
+ if (this.viralViewerApi.viralScene) {
21
+ this.composer = new effect_composer_1.EffectComposer(this.viralViewerApi.viralRenderer.renderer);
22
+ this.renderPass = new render_pass_1.RenderPass(this.viralViewerApi.viralScene.scene, this.viralViewerApi.viralCamera.camera);
23
+ this.outlinePass = new outline_pass_1.OutlinePass(new three_1.Vector2(window.innerWidth, window.innerHeight), this.viralViewerApi.viralScene.scene, this.viralViewerApi.viralCamera.camera);
24
+ this.outputPass = new output_pass_1.OutputPass();
25
+ this.shaderPass = new shader_pass_1.ShaderPass(fxaa_shader_1.FXAAShader);
26
+ this.shaderPass.uniforms["resolution"].value.set(1 / window.innerWidth, 1 / window.innerHeight);
27
+ this.composer.addPass(this.renderPass);
28
+ this.composer.addPass(this.outlinePass);
29
+ this.composer.addPass(this.outputPass);
30
+ this.composer.addPass(this.shaderPass);
31
+ }
32
+ }
33
+ }
34
+ exports.OutlineEffect = OutlineEffect;
35
+ //# sourceMappingURL=outline-effect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline-effect.js","sourceRoot":"","sources":["../../../src/components/post-processing/outline-effect.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,yFAAqF;AACrF,mFAA+E;AAC/E,iFAA6E;AAE7E,iFAA6E;AAC7E,iFAA6E;AAC7E,yEAAqE;AAErE,MAAa,aAAa;IAOxB,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QANlD,aAAQ,GAA0B,IAAI,CAAC;QACvC,QAAQ;QACR,eAAU,GAAsB,IAAI,CAAC;QACrC,gBAAW,GAAuB,IAAI,CAAC;QACvC,eAAU,GAAsB,IAAI,CAAC;QACrC,eAAU,GAAsB,IAAI,CAAC;QAEnC,IAAI,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;YAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,gCAAc,CAChC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,QAAQ,CAC3C,CAAC;YAEF,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAC9B,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EACpC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CACvC,CAAC;YAEF,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAChC,IAAI,eAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,EAClD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EACpC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CACvC,CAAC;YAEF,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,EAAE,CAAC;YAEnC,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,CAAC,wBAAU,CAAC,CAAC;YAC7C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAC9C,CAAC,GAAG,MAAM,CAAC,UAAU,EACrB,CAAC,GAAG,MAAM,CAAC,WAAW,CACvB,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACxC;IACH,CAAC;CACF;AAtCD,sCAsCC"}
@@ -0,0 +1,58 @@
1
+ export class OutlinePass extends Pass {
2
+ constructor(resolution: any, scene: any, camera: any, selectedObjects: any);
3
+ renderScene: any;
4
+ renderCamera: any;
5
+ selectedObjects: any;
6
+ visibleEdgeColor: Color;
7
+ hiddenEdgeColor: Color;
8
+ edgeGlow: number;
9
+ usePatternTexture: boolean;
10
+ edgeThickness: number;
11
+ edgeStrength: number;
12
+ downSampleRatio: number;
13
+ pulsePeriod: number;
14
+ _visibilityCache: Map<any, any>;
15
+ resolution: Vector2;
16
+ renderTargetMaskBuffer: WebGLRenderTarget;
17
+ depthMaterial: MeshDepthMaterial;
18
+ prepareMaskMaterial: ShaderMaterial;
19
+ renderTargetDepthBuffer: WebGLRenderTarget;
20
+ renderTargetMaskDownSampleBuffer: WebGLRenderTarget;
21
+ renderTargetBlurBuffer1: WebGLRenderTarget;
22
+ renderTargetBlurBuffer2: WebGLRenderTarget;
23
+ edgeDetectionMaterial: ShaderMaterial;
24
+ renderTargetEdgeBuffer1: WebGLRenderTarget;
25
+ renderTargetEdgeBuffer2: WebGLRenderTarget;
26
+ separableBlurMaterial1: ShaderMaterial;
27
+ separableBlurMaterial2: ShaderMaterial;
28
+ overlayMaterial: ShaderMaterial;
29
+ copyUniforms: any;
30
+ materialCopy: ShaderMaterial;
31
+ _oldClearColor: Color;
32
+ oldClearAlpha: number;
33
+ fsQuad: FullScreenQuad;
34
+ tempPulseColor1: Color;
35
+ tempPulseColor2: Color;
36
+ textureMatrix: Matrix4;
37
+ setSize(width: any, height: any): void;
38
+ changeVisibilityOfSelectedObjects(bVisible: any): void;
39
+ changeVisibilityOfNonSelectedObjects(bVisible: any): void;
40
+ updateTextureMatrix(): void;
41
+ render(renderer: any, writeBuffer: any, readBuffer: any, deltaTime: any, maskActive: any): void;
42
+ getPrepareMaskMaterial(): ShaderMaterial;
43
+ getEdgeDetectionMaterial(): ShaderMaterial;
44
+ getSeperableBlurMaterial(maxRadius: any): ShaderMaterial;
45
+ getOverlayMaterial(): ShaderMaterial;
46
+ }
47
+ export namespace OutlinePass {
48
+ const BlurDirectionX: Vector2;
49
+ const BlurDirectionY: Vector2;
50
+ }
51
+ import { Pass } from './pass';
52
+ import { Color } from 'three';
53
+ import { Vector2 } from 'three';
54
+ import { WebGLRenderTarget } from 'three';
55
+ import { MeshDepthMaterial } from 'three';
56
+ import { ShaderMaterial } from 'three';
57
+ import { FullScreenQuad } from './pass';
58
+ import { Matrix4 } from 'three';
@@ -0,0 +1,484 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutlinePass = void 0;
4
+ const three_1 = require("three");
5
+ const pass_1 = require("./pass");
6
+ const copy_shader_1 = require("../shaders/copy-shader");
7
+ class OutlinePass extends pass_1.Pass {
8
+ constructor(resolution, scene, camera, selectedObjects) {
9
+ super();
10
+ this.renderScene = scene;
11
+ this.renderCamera = camera;
12
+ this.selectedObjects = selectedObjects !== undefined ? selectedObjects : [];
13
+ this.visibleEdgeColor = new three_1.Color(1, 1, 1);
14
+ this.hiddenEdgeColor = new three_1.Color(0.1, 0.04, 0.02);
15
+ this.edgeGlow = 0.0;
16
+ this.usePatternTexture = false;
17
+ this.edgeThickness = 1.0;
18
+ this.edgeStrength = 3.0;
19
+ this.downSampleRatio = 2;
20
+ this.pulsePeriod = 0;
21
+ this._visibilityCache = new Map();
22
+ this.resolution = (resolution !== undefined) ? new three_1.Vector2(resolution.x, resolution.y) : new three_1.Vector2(256, 256);
23
+ const resx = Math.round(this.resolution.x / this.downSampleRatio);
24
+ const resy = Math.round(this.resolution.y / this.downSampleRatio);
25
+ this.renderTargetMaskBuffer = new three_1.WebGLRenderTarget(this.resolution.x, this.resolution.y);
26
+ this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask';
27
+ this.renderTargetMaskBuffer.texture.generateMipmaps = false;
28
+ this.depthMaterial = new three_1.MeshDepthMaterial();
29
+ this.depthMaterial.side = three_1.DoubleSide;
30
+ this.depthMaterial.depthPacking = three_1.RGBADepthPacking;
31
+ this.depthMaterial.blending = three_1.NoBlending;
32
+ this.prepareMaskMaterial = this.getPrepareMaskMaterial();
33
+ this.prepareMaskMaterial.side = three_1.DoubleSide;
34
+ this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ(this.prepareMaskMaterial.fragmentShader, this.renderCamera);
35
+ this.renderTargetDepthBuffer = new three_1.WebGLRenderTarget(this.resolution.x, this.resolution.y);
36
+ this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
37
+ this.renderTargetDepthBuffer.texture.generateMipmaps = false;
38
+ this.renderTargetMaskDownSampleBuffer = new three_1.WebGLRenderTarget(resx, resy);
39
+ this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
40
+ this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
41
+ this.renderTargetBlurBuffer1 = new three_1.WebGLRenderTarget(resx, resy);
42
+ this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
43
+ this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
44
+ this.renderTargetBlurBuffer2 = new three_1.WebGLRenderTarget(Math.round(resx / 2), Math.round(resy / 2));
45
+ this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
46
+ this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
47
+ this.edgeDetectionMaterial = this.getEdgeDetectionMaterial();
48
+ this.renderTargetEdgeBuffer1 = new three_1.WebGLRenderTarget(resx, resy);
49
+ this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
50
+ this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
51
+ this.renderTargetEdgeBuffer2 = new three_1.WebGLRenderTarget(Math.round(resx / 2), Math.round(resy / 2));
52
+ this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
53
+ this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
54
+ const MAX_EDGE_THICKNESS = 4;
55
+ const MAX_EDGE_GLOW = 4;
56
+ this.separableBlurMaterial1 = this.getSeperableBlurMaterial(MAX_EDGE_THICKNESS);
57
+ this.separableBlurMaterial1.uniforms['texSize'].value.set(resx, resy);
58
+ this.separableBlurMaterial1.uniforms['kernelRadius'].value = 1;
59
+ this.separableBlurMaterial2 = this.getSeperableBlurMaterial(MAX_EDGE_GLOW);
60
+ this.separableBlurMaterial2.uniforms['texSize'].value.set(Math.round(resx / 2), Math.round(resy / 2));
61
+ this.separableBlurMaterial2.uniforms['kernelRadius'].value = MAX_EDGE_GLOW;
62
+ // Overlay material
63
+ this.overlayMaterial = this.getOverlayMaterial();
64
+ // copy material
65
+ const copyShader = copy_shader_1.CopyShader;
66
+ this.copyUniforms = three_1.UniformsUtils.clone(copyShader.uniforms);
67
+ this.copyUniforms['opacity'].value = 1.0;
68
+ this.materialCopy = new three_1.ShaderMaterial({
69
+ uniforms: this.copyUniforms,
70
+ vertexShader: copyShader.vertexShader,
71
+ fragmentShader: copyShader.fragmentShader,
72
+ blending: three_1.NoBlending,
73
+ depthTest: false,
74
+ depthWrite: false,
75
+ transparent: true
76
+ });
77
+ this.enabled = true;
78
+ this.needsSwap = false;
79
+ this._oldClearColor = new three_1.Color();
80
+ this.oldClearAlpha = 1;
81
+ this.fsQuad = new pass_1.FullScreenQuad(null);
82
+ this.tempPulseColor1 = new three_1.Color();
83
+ this.tempPulseColor2 = new three_1.Color();
84
+ this.textureMatrix = new three_1.Matrix4();
85
+ function replaceDepthToViewZ(string, camera) {
86
+ const type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic';
87
+ return string.replace(/DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ');
88
+ }
89
+ }
90
+ dispose() {
91
+ this.renderTargetMaskBuffer.dispose();
92
+ this.renderTargetDepthBuffer.dispose();
93
+ this.renderTargetMaskDownSampleBuffer.dispose();
94
+ this.renderTargetBlurBuffer1.dispose();
95
+ this.renderTargetBlurBuffer2.dispose();
96
+ this.renderTargetEdgeBuffer1.dispose();
97
+ this.renderTargetEdgeBuffer2.dispose();
98
+ this.depthMaterial.dispose();
99
+ this.prepareMaskMaterial.dispose();
100
+ this.edgeDetectionMaterial.dispose();
101
+ this.separableBlurMaterial1.dispose();
102
+ this.separableBlurMaterial2.dispose();
103
+ this.overlayMaterial.dispose();
104
+ this.materialCopy.dispose();
105
+ this.fsQuad.dispose();
106
+ }
107
+ setSize(width, height) {
108
+ this.renderTargetMaskBuffer.setSize(width, height);
109
+ this.renderTargetDepthBuffer.setSize(width, height);
110
+ let resx = Math.round(width / this.downSampleRatio);
111
+ let resy = Math.round(height / this.downSampleRatio);
112
+ this.renderTargetMaskDownSampleBuffer.setSize(resx, resy);
113
+ this.renderTargetBlurBuffer1.setSize(resx, resy);
114
+ this.renderTargetEdgeBuffer1.setSize(resx, resy);
115
+ this.separableBlurMaterial1.uniforms['texSize'].value.set(resx, resy);
116
+ resx = Math.round(resx / 2);
117
+ resy = Math.round(resy / 2);
118
+ this.renderTargetBlurBuffer2.setSize(resx, resy);
119
+ this.renderTargetEdgeBuffer2.setSize(resx, resy);
120
+ this.separableBlurMaterial2.uniforms['texSize'].value.set(resx, resy);
121
+ }
122
+ changeVisibilityOfSelectedObjects(bVisible) {
123
+ const cache = this._visibilityCache;
124
+ function gatherSelectedMeshesCallBack(object) {
125
+ if (object.isMesh) {
126
+ if (bVisible === true) {
127
+ object.visible = cache.get(object);
128
+ }
129
+ else {
130
+ cache.set(object, object.visible);
131
+ object.visible = bVisible;
132
+ }
133
+ }
134
+ }
135
+ for (let i = 0; i < this.selectedObjects.length; i++) {
136
+ const selectedObject = this.selectedObjects[i];
137
+ selectedObject.traverse(gatherSelectedMeshesCallBack);
138
+ }
139
+ }
140
+ changeVisibilityOfNonSelectedObjects(bVisible) {
141
+ const cache = this._visibilityCache;
142
+ const selectedMeshes = [];
143
+ function gatherSelectedMeshesCallBack(object) {
144
+ if (object.isMesh)
145
+ selectedMeshes.push(object);
146
+ }
147
+ for (let i = 0; i < this.selectedObjects.length; i++) {
148
+ const selectedObject = this.selectedObjects[i];
149
+ selectedObject.traverse(gatherSelectedMeshesCallBack);
150
+ }
151
+ function VisibilityChangeCallBack(object) {
152
+ if (object.isMesh || object.isSprite) {
153
+ // only meshes and sprites are supported by OutlinePass
154
+ let bFound = false;
155
+ for (let i = 0; i < selectedMeshes.length; i++) {
156
+ const selectedObjectId = selectedMeshes[i].id;
157
+ if (selectedObjectId === object.id) {
158
+ bFound = true;
159
+ break;
160
+ }
161
+ }
162
+ if (bFound === false) {
163
+ const visibility = object.visible;
164
+ if (bVisible === false || cache.get(object) === true) {
165
+ object.visible = bVisible;
166
+ }
167
+ cache.set(object, visibility);
168
+ }
169
+ }
170
+ else if (object.isPoints || object.isLine) {
171
+ // the visibilty of points and lines is always set to false in order to
172
+ // not affect the outline computation
173
+ if (bVisible === true) {
174
+ object.visible = cache.get(object); // restore
175
+ }
176
+ else {
177
+ cache.set(object, object.visible);
178
+ object.visible = bVisible;
179
+ }
180
+ }
181
+ }
182
+ this.renderScene.traverse(VisibilityChangeCallBack);
183
+ }
184
+ updateTextureMatrix() {
185
+ this.textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
186
+ this.textureMatrix.multiply(this.renderCamera.projectionMatrix);
187
+ this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse);
188
+ }
189
+ render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
190
+ if (this.selectedObjects.length > 0) {
191
+ renderer.getClearColor(this._oldClearColor);
192
+ this.oldClearAlpha = renderer.getClearAlpha();
193
+ const oldAutoClear = renderer.autoClear;
194
+ renderer.autoClear = false;
195
+ if (maskActive)
196
+ renderer.state.buffers.stencil.setTest(false);
197
+ renderer.setClearColor(0xffffff, 1);
198
+ // Make selected objects invisible
199
+ this.changeVisibilityOfSelectedObjects(false);
200
+ const currentBackground = this.renderScene.background;
201
+ this.renderScene.background = null;
202
+ // 1. Draw Non Selected objects in the depth buffer
203
+ this.renderScene.overrideMaterial = this.depthMaterial;
204
+ renderer.setRenderTarget(this.renderTargetDepthBuffer);
205
+ renderer.clear();
206
+ renderer.render(this.renderScene, this.renderCamera);
207
+ // Make selected objects visible
208
+ this.changeVisibilityOfSelectedObjects(true);
209
+ this._visibilityCache.clear();
210
+ // Update Texture Matrix for Depth compare
211
+ this.updateTextureMatrix();
212
+ // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects
213
+ this.changeVisibilityOfNonSelectedObjects(false);
214
+ this.renderScene.overrideMaterial = this.prepareMaskMaterial;
215
+ this.prepareMaskMaterial.uniforms['cameraNearFar'].value.set(this.renderCamera.near, this.renderCamera.far);
216
+ this.prepareMaskMaterial.uniforms['depthTexture'].value = this.renderTargetDepthBuffer.texture;
217
+ this.prepareMaskMaterial.uniforms['textureMatrix'].value = this.textureMatrix;
218
+ renderer.setRenderTarget(this.renderTargetMaskBuffer);
219
+ renderer.clear();
220
+ renderer.render(this.renderScene, this.renderCamera);
221
+ this.renderScene.overrideMaterial = null;
222
+ this.changeVisibilityOfNonSelectedObjects(true);
223
+ this._visibilityCache.clear();
224
+ this.renderScene.background = currentBackground;
225
+ // 2. Downsample to Half resolution
226
+ this.fsQuad.material = this.materialCopy;
227
+ this.copyUniforms['tDiffuse'].value = this.renderTargetMaskBuffer.texture;
228
+ renderer.setRenderTarget(this.renderTargetMaskDownSampleBuffer);
229
+ renderer.clear();
230
+ this.fsQuad.render(renderer);
231
+ this.tempPulseColor1.copy(this.visibleEdgeColor);
232
+ this.tempPulseColor2.copy(this.hiddenEdgeColor);
233
+ if (this.pulsePeriod > 0) {
234
+ const scalar = (1 + 0.25) / 2 + Math.cos(performance.now() * 0.01 / this.pulsePeriod) * (1.0 - 0.25) / 2;
235
+ this.tempPulseColor1.multiplyScalar(scalar);
236
+ this.tempPulseColor2.multiplyScalar(scalar);
237
+ }
238
+ // 3. Apply Edge Detection Pass
239
+ this.fsQuad.material = this.edgeDetectionMaterial;
240
+ this.edgeDetectionMaterial.uniforms['maskTexture'].value = this.renderTargetMaskDownSampleBuffer.texture;
241
+ this.edgeDetectionMaterial.uniforms['texSize'].value.set(this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height);
242
+ this.edgeDetectionMaterial.uniforms['visibleEdgeColor'].value = this.tempPulseColor1;
243
+ this.edgeDetectionMaterial.uniforms['hiddenEdgeColor'].value = this.tempPulseColor2;
244
+ renderer.setRenderTarget(this.renderTargetEdgeBuffer1);
245
+ renderer.clear();
246
+ this.fsQuad.render(renderer);
247
+ // 4. Apply Blur on Half res
248
+ this.fsQuad.material = this.separableBlurMaterial1;
249
+ this.separableBlurMaterial1.uniforms['colorTexture'].value = this.renderTargetEdgeBuffer1.texture;
250
+ this.separableBlurMaterial1.uniforms['direction'].value = OutlinePass.BlurDirectionX;
251
+ this.separableBlurMaterial1.uniforms['kernelRadius'].value = this.edgeThickness;
252
+ renderer.setRenderTarget(this.renderTargetBlurBuffer1);
253
+ renderer.clear();
254
+ this.fsQuad.render(renderer);
255
+ this.separableBlurMaterial1.uniforms['colorTexture'].value = this.renderTargetBlurBuffer1.texture;
256
+ this.separableBlurMaterial1.uniforms['direction'].value = OutlinePass.BlurDirectionY;
257
+ renderer.setRenderTarget(this.renderTargetEdgeBuffer1);
258
+ renderer.clear();
259
+ this.fsQuad.render(renderer);
260
+ // Apply Blur on quarter res
261
+ this.fsQuad.material = this.separableBlurMaterial2;
262
+ this.separableBlurMaterial2.uniforms['colorTexture'].value = this.renderTargetEdgeBuffer1.texture;
263
+ this.separableBlurMaterial2.uniforms['direction'].value = OutlinePass.BlurDirectionX;
264
+ renderer.setRenderTarget(this.renderTargetBlurBuffer2);
265
+ renderer.clear();
266
+ this.fsQuad.render(renderer);
267
+ this.separableBlurMaterial2.uniforms['colorTexture'].value = this.renderTargetBlurBuffer2.texture;
268
+ this.separableBlurMaterial2.uniforms['direction'].value = OutlinePass.BlurDirectionY;
269
+ renderer.setRenderTarget(this.renderTargetEdgeBuffer2);
270
+ renderer.clear();
271
+ this.fsQuad.render(renderer);
272
+ // Blend it additively over the input texture
273
+ this.fsQuad.material = this.overlayMaterial;
274
+ this.overlayMaterial.uniforms['maskTexture'].value = this.renderTargetMaskBuffer.texture;
275
+ this.overlayMaterial.uniforms['edgeTexture1'].value = this.renderTargetEdgeBuffer1.texture;
276
+ this.overlayMaterial.uniforms['edgeTexture2'].value = this.renderTargetEdgeBuffer2.texture;
277
+ this.overlayMaterial.uniforms['patternTexture'].value = this.patternTexture;
278
+ this.overlayMaterial.uniforms['edgeStrength'].value = this.edgeStrength;
279
+ this.overlayMaterial.uniforms['edgeGlow'].value = this.edgeGlow;
280
+ this.overlayMaterial.uniforms['usePatternTexture'].value = this.usePatternTexture;
281
+ if (maskActive)
282
+ renderer.state.buffers.stencil.setTest(true);
283
+ renderer.setRenderTarget(readBuffer);
284
+ this.fsQuad.render(renderer);
285
+ renderer.setClearColor(this._oldClearColor, this.oldClearAlpha);
286
+ renderer.autoClear = oldAutoClear;
287
+ }
288
+ if (this.renderToScreen) {
289
+ this.fsQuad.material = this.materialCopy;
290
+ this.copyUniforms['tDiffuse'].value = readBuffer.texture;
291
+ renderer.setRenderTarget(null);
292
+ this.fsQuad.render(renderer);
293
+ }
294
+ }
295
+ getPrepareMaskMaterial() {
296
+ return new three_1.ShaderMaterial({
297
+ uniforms: {
298
+ 'depthTexture': { value: null },
299
+ 'cameraNearFar': { value: new three_1.Vector2(0.5, 0.5) },
300
+ 'textureMatrix': { value: null }
301
+ },
302
+ vertexShader: `#include <morphtarget_pars_vertex>
303
+ #include <skinning_pars_vertex>
304
+
305
+ varying vec4 projTexCoord;
306
+ varying vec4 vPosition;
307
+ uniform mat4 textureMatrix;
308
+
309
+ void main() {
310
+
311
+ #include <skinbase_vertex>
312
+ #include <begin_vertex>
313
+ #include <morphtarget_vertex>
314
+ #include <skinning_vertex>
315
+ #include <project_vertex>
316
+
317
+ vPosition = mvPosition;
318
+
319
+ vec4 worldPosition = vec4( transformed, 1.0 );
320
+
321
+ #ifdef USE_INSTANCING
322
+
323
+ worldPosition = instanceMatrix * worldPosition;
324
+
325
+ #endif
326
+
327
+ worldPosition = modelMatrix * worldPosition;
328
+
329
+ projTexCoord = textureMatrix * worldPosition;
330
+
331
+ }`,
332
+ fragmentShader: `#include <packing>
333
+ varying vec4 vPosition;
334
+ varying vec4 projTexCoord;
335
+ uniform sampler2D depthTexture;
336
+ uniform vec2 cameraNearFar;
337
+
338
+ void main() {
339
+
340
+ float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));
341
+ float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );
342
+ float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;
343
+ gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);
344
+
345
+ }`
346
+ });
347
+ }
348
+ getEdgeDetectionMaterial() {
349
+ return new three_1.ShaderMaterial({
350
+ uniforms: {
351
+ 'maskTexture': { value: null },
352
+ 'texSize': { value: new three_1.Vector2(0.5, 0.5) },
353
+ 'visibleEdgeColor': { value: new three_1.Vector3(1.0, 1.0, 1.0) },
354
+ 'hiddenEdgeColor': { value: new three_1.Vector3(1.0, 1.0, 1.0) },
355
+ },
356
+ vertexShader: `varying vec2 vUv;
357
+
358
+ void main() {
359
+ vUv = uv;
360
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
361
+ }`,
362
+ fragmentShader: `varying vec2 vUv;
363
+
364
+ uniform sampler2D maskTexture;
365
+ uniform vec2 texSize;
366
+ uniform vec3 visibleEdgeColor;
367
+ uniform vec3 hiddenEdgeColor;
368
+
369
+ void main() {
370
+ vec2 invSize = 1.0 / texSize;
371
+ vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);
372
+ vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);
373
+ vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);
374
+ vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);
375
+ vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);
376
+ float diff1 = (c1.r - c2.r)*0.5;
377
+ float diff2 = (c3.r - c4.r)*0.5;
378
+ float d = length( vec2(diff1, diff2) );
379
+ float a1 = min(c1.g, c2.g);
380
+ float a2 = min(c3.g, c4.g);
381
+ float visibilityFactor = min(a1, a2);
382
+ vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
383
+ gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);
384
+ }`
385
+ });
386
+ }
387
+ getSeperableBlurMaterial(maxRadius) {
388
+ return new three_1.ShaderMaterial({
389
+ defines: {
390
+ 'MAX_RADIUS': maxRadius,
391
+ },
392
+ uniforms: {
393
+ 'colorTexture': { value: null },
394
+ 'texSize': { value: new three_1.Vector2(0.5, 0.5) },
395
+ 'direction': { value: new three_1.Vector2(0.5, 0.5) },
396
+ 'kernelRadius': { value: 1.0 }
397
+ },
398
+ vertexShader: `varying vec2 vUv;
399
+
400
+ void main() {
401
+ vUv = uv;
402
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
403
+ }`,
404
+ fragmentShader: `#include <common>
405
+ varying vec2 vUv;
406
+ uniform sampler2D colorTexture;
407
+ uniform vec2 texSize;
408
+ uniform vec2 direction;
409
+ uniform float kernelRadius;
410
+
411
+ float gaussianPdf(in float x, in float sigma) {
412
+ return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
413
+ }
414
+
415
+ void main() {
416
+ vec2 invSize = 1.0 / texSize;
417
+ float sigma = kernelRadius/2.0;
418
+ float weightSum = gaussianPdf(0.0, sigma);
419
+ vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;
420
+ vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);
421
+ vec2 uvOffset = delta;
422
+ for( int i = 1; i <= MAX_RADIUS; i ++ ) {
423
+ float x = kernelRadius * float(i) / float(MAX_RADIUS);
424
+ float w = gaussianPdf(x, sigma);
425
+ vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);
426
+ vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);
427
+ diffuseSum += ((sample1 + sample2) * w);
428
+ weightSum += (2.0 * w);
429
+ uvOffset += delta;
430
+ }
431
+ gl_FragColor = diffuseSum/weightSum;
432
+ }`
433
+ });
434
+ }
435
+ getOverlayMaterial() {
436
+ return new three_1.ShaderMaterial({
437
+ uniforms: {
438
+ 'maskTexture': { value: null },
439
+ 'edgeTexture1': { value: null },
440
+ 'edgeTexture2': { value: null },
441
+ 'patternTexture': { value: null },
442
+ 'edgeStrength': { value: 1.0 },
443
+ 'edgeGlow': { value: 1.0 },
444
+ 'usePatternTexture': { value: 0.0 }
445
+ },
446
+ vertexShader: `varying vec2 vUv;
447
+
448
+ void main() {
449
+ vUv = uv;
450
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
451
+ }`,
452
+ fragmentShader: `varying vec2 vUv;
453
+
454
+ uniform sampler2D maskTexture;
455
+ uniform sampler2D edgeTexture1;
456
+ uniform sampler2D edgeTexture2;
457
+ uniform sampler2D patternTexture;
458
+ uniform float edgeStrength;
459
+ uniform float edgeGlow;
460
+ uniform bool usePatternTexture;
461
+
462
+ void main() {
463
+ vec4 edgeValue1 = texture2D(edgeTexture1, vUv);
464
+ vec4 edgeValue2 = texture2D(edgeTexture2, vUv);
465
+ vec4 maskColor = texture2D(maskTexture, vUv);
466
+ vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);
467
+ float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;
468
+ vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;
469
+ vec4 finalColor = edgeStrength * maskColor.r * edgeValue;
470
+ if(usePatternTexture)
471
+ finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);
472
+ gl_FragColor = finalColor;
473
+ }`,
474
+ blending: three_1.AdditiveBlending,
475
+ depthTest: false,
476
+ depthWrite: false,
477
+ transparent: true
478
+ });
479
+ }
480
+ }
481
+ exports.OutlinePass = OutlinePass;
482
+ OutlinePass.BlurDirectionX = new three_1.Vector2(1.0, 0.0);
483
+ OutlinePass.BlurDirectionY = new three_1.Vector2(0.0, 1.0);
484
+ //# sourceMappingURL=outline-pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline-pass.js","sourceRoot":"","sources":["../../../src/threejs-addon/post-processing/outline-pass.js"],"names":[],"mappings":";;;AAAA,iCAae;AACf,iCAA8C;AAC9C,wDAAoD;AAEpD,MAAM,WA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G,CAAC,EAAE;gBAC7C,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;aACjC;YAED,YAAY,EAAE;;;;;MAKpB;YAEM,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4BtB;SACG,CAAC,CAAC;IAEP,CAAC;IAED,kBAAkB;QAEd,OAAO,IAAI,sBAAc,CAAC;YAEtB,QAAQ,EAAE;gBACN,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC9B,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC/B,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC/B,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;gBACjC,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;gBAC9B,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;gBAC1B,mBAAmB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;aACtC;YAED,YAAY,EAAE;;;;;MAKpB;YAEM,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;MAqBtB;YACM,QAAQ,EAAE,wBAAgB;YAC1B,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;IAEP,CAAC;CAEJ;AAKQ,kCAAW;AAHpB,WAAW,CAAC,cAAc,GAAG,IAAI,eAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACnD,WAAW,CAAC,cAAc,GAAG,IAAI,eAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fxaa-shader.js","sourceRoot":"","sources":["../../../src/threejs-addon/shaders/fxaa-shader.js"],"names":[],"mappings":";;;AAAA,iCAEe;AAEf;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG;IAEf,QAAQ,EAAE;QAEN,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;QAC3B,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,eAAO,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE;KAE1D;IAED,YAAY,EAAE,UAAU,CAAC;;;;;;;;;IASzB;IAEA,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyPlB;CAED,CAAC;AAEO,gCAAU"}
@@ -15,6 +15,7 @@ import { ViralContextMenu } from "./components/context-menu/viral-context-menu";
15
15
  import { ViralCentralizedEventHandler } from "./components/centralized-event-handler/viral-centralized-event-handler";
16
16
  import { ViralLoader } from "./components/loader/viral.loader";
17
17
  import { ViralStats } from "./components/stats/viral-stats";
18
+ import { OutlineEffect } from "./components/post-processing/outline-effect";
18
19
  export declare class ViralViewerApi {
19
20
  options: ViewerOptions;
20
21
  targetElement: HTMLElement;
@@ -30,6 +31,7 @@ export declare class ViralViewerApi {
30
31
  viralAnimation: ViralAnimation;
31
32
  viralCentralizedEventHandler: ViralCentralizedEventHandler;
32
33
  viralLoader: ViralLoader;
34
+ outlineEffect: OutlineEffect;
33
35
  viralCompressProcessor: ViralCompressProcessor;
34
36
  worker3: ViralViewerWorker3;
35
37
  localStorageService: LocalStorageService;
@@ -17,9 +17,9 @@ const viral_context_menu_1 = require("./components/context-menu/viral-context-me
17
17
  const viral_centralized_event_handler_1 = require("./components/centralized-event-handler/viral-centralized-event-handler");
18
18
  const viral_loader_1 = require("./components/loader/viral.loader");
19
19
  const viral_stats_1 = require("./components/stats/viral-stats");
20
+ const outline_effect_1 = require("./components/post-processing/outline-effect");
20
21
  class ViralViewerApi {
21
22
  constructor(options) {
22
- // viralPostProcessing:ViralPostProcessing;
23
23
  this.viralCompressProcessor = new viral_compress_processor_1.ViralCompressProcessor();
24
24
  this.localStorageService = new local_storage_service_1.LocalStorageService();
25
25
  this.viralStats = null;
@@ -36,13 +36,16 @@ class ViralViewerApi {
36
36
  this.viralKeyboard = new viral_keyboard_1.ViralKeyboard(this);
37
37
  this.viralAnimation = new viral_animation_1.ViralAnimation(this);
38
38
  // this.viralPostProcessing = new ViralPostProcessing(this);
39
+ this.outlineEffect = new outline_effect_1.OutlineEffect(this);
39
40
  this.viralCentralizedEventHandler = new viral_centralized_event_handler_1.ViralCentralizedEventHandler(this);
40
41
  this.viralLoader = new viral_loader_1.ViralLoader(this);
41
42
  this.worker3 = new viral_viewer_3_worker_1.ViralViewerWorker3(this);
42
43
  if (this.options.isDev) {
43
44
  this.viralStats = new viral_stats_1.ViralStats(this);
44
45
  }
45
- this.options.isDev ? this.viralAnimation.devAnimation() : this.viralAnimation.animation();
46
+ this.options.isDev
47
+ ? this.viralAnimation.devAnimation()
48
+ : this.viralAnimation.animation();
46
49
  }
47
50
  }
48
51
  exports.ViralViewerApi = ViralViewerApi;
@@ -1 +1 @@
1
- {"version":3,"file":"viral-viewer-api.js","s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,6 +1,6 @@
1
1
  {
2
2
  "name": "viral-viewer-2",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",