OK here you go;
1. You need Lensflare.js in you app directory.
Lensflare.js
2. Enable your app to import modules in your myapp.html file.
<script src="v3d.js"></script>
<script type="module" src="myapp.js"></script>
3. Import Lensflare module to your myapp.js file.
import * as verge from '../../build/v3d.module.js';
import { Lensflare, LensflareElement } from './Lensflare.js';
This needs to be on top of your file after “use strict” line.
4. Add an omnilight on your scene as “Omni001” in your 3D application (blender or max or maya)
5. Add lensflare textures on your app directory inside (../textures/lensflare/).
6. Add lensflare code to your runcode section.
var textureLoader = new v3d.TextureLoader();
var textureFlare0 = textureLoader.load('textures/lensflare/lensflare0.png');
var textureFlare3 = textureLoader.load('textures/lensflare/lensflare3.png');
var light = app.scene.getObjectByName('Omni001');
var lensflare = new Lensflare();
lensflare.addElement(new LensflareElement(textureFlare0, 700, 0, light.color));
lensflare.addElement(new LensflareElement(textureFlare3, 60, 0.6));
lensflare.addElement(new LensflareElement(textureFlare3, 70, 0.7));
lensflare.addElement(new LensflareElement(textureFlare3, 120, 0.9));
lensflare.addElement(new LensflareElement(textureFlare3, 70, 1));
light.add(lensflare);
Thats all.
Happy lensflaring.
Thanks to zjbcool for his awesome example about importing modules.