Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- https://vorillaz.com/chen-lee-attractor  -->
              
            
!

CSS

              
                /* https://vorillaz.com/chen-lee-attractor */
              
            
!

JS

              
                const alpha = 5;
const beta = -10;
const delta = -0.38;

const dt = 0.001;

const particlesNumber = 100000;


let canvasWidth;
let canvasHeight;
let midX;
let midY;

const far = 2000;

const scene = new THREE.Scene();

const system = new THREE.Object3D();
scene.add(system);

const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xfafafa);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.shadowMap.enabled = false;

const light = new THREE.DirectionalLight(0xffffff);
light.position.set(0.5, 100, 0);
scene.add(light);
scene.fog = new THREE.Fog(0x000000, 100, 1);

// camera
const camera = new THREE.PerspectiveCamera(-80, window.innerWidth / window.innerHeight, 1, far);
camera.position.set(-60, 630, 970);

// controller
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.9;
controls.enableZoom = true;
controls.minDistance = 100;
// controls.maxDistance = 1400;

const summon = () => {
  canvasWidth = window.innerWidth;
  canvasHeight = window.innerHeight;
  midX = canvasWidth >> 1;
  midY = canvasHeight >> 1;
};

const init = () => {
  const scale = 10;

  let x = 0.4;
  let y = 0.3;
  let z = 0.1;

  let maxHeight = 0;
  let maxDepth = 0;
  const points = [];

  // calculate points for attractor and push them in the geometry
  for (let i = 0; i < particlesNumber; i++) {
let x1 = alpha * x - y * z;
    let y1 = beta * y + x * z;
    let z1 = delta * z + (x * y) / 3;

    x1 *= dt;
    y1 *= dt;
    z1 *= dt;

    x += x1;
    y += y1;
    z += z1;
    const vector = new THREE.Vector3(x * scale, y * scale, z * scale);
    points.push(vector);
  }

  const spline = new THREE.CatmullRomCurve3(points);
  spline.type = 'catmullrom';
  spline.tension = 0;

  const extrudeSettings = {
    steps: particlesNumber / 2,
    bevelEnabled: false,
    extrudePath: spline
  };

  const shaped = [];
  const width = 4;

  shaped.push(new THREE.Vector2(0, 0));
  shaped.push(new THREE.Vector2(width, 0));
  shaped.push(new THREE.Vector2(width, width));
  shaped.push(new THREE.Vector2(0, width));

  const shape = new THREE.Shape(shaped);
  const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
  const material = new THREE.MeshLambertMaterial({
    color: 0xffffff,
    shading: THREE.FlatShading,
    vertexColors: THREE.VertexColors
  });

  const mesh = new THREE.Mesh(geometry, material);
  mesh.castShadow = true;
  mesh.receiveShadow = false;
  system.add(mesh);
};

const boot = () => {
  renderer.render(scene, camera);
  requestAnimationFrame(boot);
};

window.addEventListener('resize', () => {
  summon();
  camera.aspect = canvasWidth / canvasHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(canvasWidth, canvasHeight);
});

summon();
init();
boot();

document.body.appendChild(renderer.domElement);

              
            
!
999px

Console