Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                

              
            
!

CSS

              
                html,
body {
  margin: 0;
  padding: 0;
}
html {
  overflow: hidden;
}

              
            
!

JS

              
                import * as THREE from 'https://cdn.skypack.dev/three';

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
  25, // FOV (field of view) in Grad
  window.innerWidth / window.innerHeight, // Verhältnis des render context
  0.1, // near - Objekte mit einer kleineren Distanz als dieser Wert werden nicht angezeigt
  1000 // far - Objekte mit einer größeren Distanz als dieser Wert werden nicht angezeigt
);

const renderer = new THREE.WebGLRenderer(); // ein von THREE.js erzeugtes <canvas> Element
renderer.setSize(window.innerWidth, window.innerHeight); // Größe des Canvas
document.body.appendChild(renderer.domElement);
scene.background = new THREE.Color( 0x20252f ); //Setting the canvas background-color

const geometry = new THREE.TorusKnotGeometry(6, 2, 250, 32);
const material = new THREE.MeshBasicMaterial({ color: 0x66D9EF });
const torus = new THREE.Mesh(geometry, material);
scene.add(torus); // Der Torus wird zur Szene hinzugefügt

// Damit das noch etwas besser aussieht wird ein wireframe auf den Torus gelegt
const wireframe = new THREE.WireframeGeometry(geometry);
const line = new THREE.LineSegments(wireframe);
line.material.depthTest = true;
line.material.opacity = 0.25;
line.material.color = new THREE.Color("#000");
line.material.transparent = true;

scene.add(line);
camera.position.z = 70; // Die Position der Kamera muss angepasst werden, damit die Objekte zu sehen sind

const meshes = [torus, line];
function draw() {
  requestAnimationFrame(draw);
  meshes.forEach((element) => {
    element.rotation.x += 0.001;
    element.rotation.y += 0.011;
  });
  renderer.render(scene, camera);
}
draw();

              
            
!
999px

Console