* Constructs a new outline effect. * * @param {Scene} scene - The main scene. * @param {Camera} camera - The main camera. * @param {Object} [options] - The options. * @param {BlendFunction} [options.blendFunction=BlendFunction.SCREEN] - The blend function. Use `BlendFunction.ALPHA` for dar
(scene, camera, {
blendFunction = BlendFunction.SCREEN,
patternTexture = null,
patternScale = 1.0,
edgeStrength = 1.0,
pulseSpeed = 0.0,
visibleEdgeColor = 0xffffff,
hiddenEdgeColor = 0x22090a,
kernelSize = KernelSize.VERY_SMALL,
blur = false,
xRay = true,
multisampling = 0,
resolutionScale = 0.5,
width = Resolution.AUTO_SIZE,
height = Resolution.AUTO_SIZE,
resolutionX = width,
resolutionY = height
} = {})
| 46 | */ |
| 47 | |
| 48 | constructor(scene, camera, { |
| 49 | blendFunction = BlendFunction.SCREEN, |
| 50 | patternTexture = null, |
| 51 | patternScale = 1.0, |
| 52 | edgeStrength = 1.0, |
| 53 | pulseSpeed = 0.0, |
| 54 | visibleEdgeColor = 0xffffff, |
| 55 | hiddenEdgeColor = 0x22090a, |
| 56 | kernelSize = KernelSize.VERY_SMALL, |
| 57 | blur = false, |
| 58 | xRay = true, |
| 59 | multisampling = 0, |
| 60 | resolutionScale = 0.5, |
| 61 | width = Resolution.AUTO_SIZE, |
| 62 | height = Resolution.AUTO_SIZE, |
| 63 | resolutionX = width, |
| 64 | resolutionY = height |
| 65 | } = {}) { |
| 66 | |
| 67 | super("OutlineEffect", fragmentShader, { |
| 68 | uniforms: new Map([ |
| 69 | ["maskTexture", new Uniform(null)], |
| 70 | ["edgeTexture", new Uniform(null)], |
| 71 | ["edgeStrength", new Uniform(edgeStrength)], |
| 72 | ["visibleEdgeColor", new Uniform(new Color(visibleEdgeColor))], |
| 73 | ["hiddenEdgeColor", new Uniform(new Color(hiddenEdgeColor))], |
| 74 | ["pulse", new Uniform(1.0)], |
| 75 | ["patternScale", new Uniform(patternScale)], |
| 76 | ["patternTexture", new Uniform(null)] |
| 77 | ]) |
| 78 | }); |
| 79 | |
| 80 | // Handle alpha blending. |
| 81 | this.blendMode.addEventListener("change", (event) => { |
| 82 | |
| 83 | if(this.blendMode.blendFunction === BlendFunction.ALPHA) { |
| 84 | |
| 85 | this.defines.set("ALPHA", "1"); |
| 86 | |
| 87 | } else { |
| 88 | |
| 89 | this.defines.delete("ALPHA"); |
| 90 | |
| 91 | } |
| 92 | |
| 93 | this.setChanged(); |
| 94 | |
| 95 | }); |
| 96 | |
| 97 | this.blendMode.blendFunction = blendFunction; |
| 98 | this.patternTexture = patternTexture; |
| 99 | this.xRay = xRay; |
| 100 | |
| 101 | /** |
| 102 | * The main scene. |
| 103 | * |
| 104 | * @type {Scene} |
| 105 | * @private |
nothing calls this directly
no test coverage detected