Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const size = 0.65;
const material = new THREE.ShaderMaterial({
uniforms: this.uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
});
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(size, 0.3, 30, 30),
material
);
mesh.rotation.x = 0.3;
this.scene.add(mesh);
this.mesh = mesh;
this.scene.add(new THREE.AmbientLight(0xcccccc));
this.light = new THREE.DirectionalLight(0xffffff, 2);
this.light.position.set(1, 1, 0.5);
this.scene.add(this.light);
// this.renderer.autoClear = false;
require('three/examples/js/postprocessing/EffectComposer');
require('three/examples/js/postprocessing/RenderPass');
require('three/examples/js/postprocessing/ShaderPass');
require('three/examples/js/postprocessing/MaskPass');
require('three/examples/js/shaders/ConvolutionShader');
require('three/examples/js/shaders/FilmShader');
require('three/examples/js/postprocessing/BloomPass');
require('three/examples/js/postprocessing/FilmPass');
require('three/examples/js/shaders/CopyShader');
const renderModel = new THREE.RenderPass(this.scene, this.camera);
setupLights = () => {
// lights
const directionalLightA = new THREE.DirectionalLight(0xffffff);
directionalLightA.position.set(1, 1, 1);
this.scene.add(directionalLightA);
const directionalLightB = new THREE.DirectionalLight(0xffeedd);
directionalLightB.position.set(-1, -1, -1);
this.scene.add(directionalLightB);
const ambientLight = new THREE.AmbientLight(0x222222);
this.scene.add(ambientLight);
};
getShadowLight = () => {
let light = new THREE.DirectionalLight(0xffffff, 0.6);
light.castShadow = true;
// default is 50
const shadowSize = 1;
light.shadow.camera.left = -shadowSize;
light.shadow.camera.right = shadowSize;
light.shadow.camera.top = shadowSize;
light.shadow.camera.bottom = -shadowSize;
light.shadow.camera.near = 0.001;
light.shadow.camera.far = 100;
light.shadow.camera.updateProjectionMatrix();
// default is 512
light.shadow.mapSize.width = 512;
light.shadow.mapSize.height = light.shadow.mapSize.width;
async setupModels() {
await super.setupModels();
this.scene.add(new THREE.AmbientLight(0xcccccc));
this.light = new THREE.DirectionalLight(0xffffff, 2);
this.light.position.set(1, 1, 0.5);
this.scene.add(this.light);
let skyMaterial = new SkyMaterial();
const skyGeo = new THREE.SphereBufferGeometry(14500, 32, 15);
// Expose variables
this.mesh = new THREE.Mesh(skyGeo, skyMaterial);
this.scene.add(this.mesh);
// Add Sun Helper
let sunSphere = new THREE.Mesh(
new THREE.SphereBufferGeometry(2000, 16, 8),
new THREE.MeshBasicMaterial({ color: 0xffffff })
);
sunSphere.position.y = -700000;
this.scene.add(sunSphere);
async setupModels() {
await super.setupModels();
this.mesh = new RandomJunkNode();
await this.mesh.loadAsync();
this.scene.add(this.mesh);
this.scene.add(new THREE.AmbientLight(0x222222));
this.light = new THREE.DirectionalLight(0xffffff);
this.light.position.set(1, 1, 1);
this.scene.add(this.light);
if (!THREE.ParallaxBarrierEffect)
require('three/examples/js/effects/ParallaxBarrierEffect');
this.effect = new THREE.ParallaxBarrierEffect(this.renderer);
const { width, height } = this.renderer.getSize();
this.effect.setSize(width, height);
}
get shadow() {
let light = new THREE.DirectionalLight(0xffffff, 0.9);
light.position.set(0, 30, 35);
return light;
}
async setupModels() {
await super.setupModels();
this.mesh = new RandomJunkNode();
await this.mesh.loadAsync();
this.scene.add(this.mesh);
this.scene.add(new THREE.AmbientLight(0x222222));
this.light = new THREE.DirectionalLight(0xffffff);
this.light.position.set(1, 1, 1);
this.scene.add(this.light);
require('three/examples/js/postprocessing/EffectComposer');
require('three/examples/js/postprocessing/RenderPass');
require('three/examples/js/postprocessing/ShaderPass');
require('three/examples/js/postprocessing/MaskPass');
require('three/examples/js/postprocessing/GlitchPass');
require('three/examples/js/postprocessing/BloomPass');
require('three/examples/js/postprocessing/FilmPass');
require('three/examples/js/shaders/CopyShader');
require('three/examples/js/shaders/ColorCorrectionShader');
require('three/examples/js/shaders/VignetteShader');
require('three/examples/js/shaders/DigitalGlitch');
const composer = new THREE.EffectComposer(this.renderer);
async setupModels() {
await super.setupModels();
this.mesh = new RandomJunkNode();
await this.mesh.loadAsync();
this.scene.add(this.mesh);
this.scene.add(new THREE.AmbientLight(0x222222));
this.light = new THREE.DirectionalLight(0xffffff);
this.light.position.set(1, 1, 1);
this.scene.add(this.light);
if (!THREE.AnaglyphEffect)
require('three/examples/js/effects/AnaglyphEffect');
this.effect = new THREE.AnaglyphEffect(this.renderer);
const { width, height } = this.renderer.getSize();
this.effect.setSize(width, height);
}
async setupModels() {
await super.setupModels();
this.mesh = new RandomJunkNode();
await this.mesh.loadAsync();
this.scene.add(this.mesh);
this.scene.add(new THREE.AmbientLight(0x222222));
this.light = new THREE.DirectionalLight(0xffffff);
this.light.position.set(1, 1, 1);
this.scene.add(this.light);
require('three/examples/js/postprocessing/EffectComposer');
require('three/examples/js/postprocessing/RenderPass');
require('three/examples/js/postprocessing/ShaderPass');
require('three/examples/js/postprocessing/MaskPass');
require('three/examples/js/postprocessing/GlitchPass');
require('three/examples/js/postprocessing/BloomPass');
require('three/examples/js/postprocessing/FilmPass');
require('three/examples/js/shaders/CopyShader');
require('three/examples/js/shaders/ColorCorrectionShader');
require('three/examples/js/shaders/VignetteShader');
require('three/examples/js/shaders/DigitalGlitch');
this.effect = new THREE.EffectComposer(this.renderer);