Pen Settings



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


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


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.


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.


    <script type="text/javascript"src=""></script>
        <script type="text/javascript" src="[email protected]/examples/js/controls/OrbitControls.js"></script>
        body {
            /* set margin to 0 and overflow to hidden, to go fullscreen */
            margin: 0;
            overflow: hidden;

<div id="WebGL-output">

    <script type="text/javascript">

        const scene = new THREE.Scene();

        const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);

        const webGLRenderer = new THREE.WebGLRenderer();
        webGLRenderer.setClearColor(new THREE.Color(0x000000));
        webGLRenderer.setSize(window.innerWidth, window.innerHeight);

        camera.position.x = -30;
        camera.position.y = 40;
        camera.position.z = 50;
        camera.lookAt(new THREE.Vector3(10, 0, 0));
       // 滑らかにカメラコントローラーを制御する
       const controls = new THREE.OrbitControls(camera, document.body);
       controls.enableDamping = true;
       controls.dampingFactor = 0.2;


        function generate() {
            const canvas = document.createElement('canvas');
            canvas.width = 16;
            canvas.height = 16;

            const context = canvas.getContext('2d');
            const gradient = context.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2);
            gradient.addColorStop(0, 'rgba(255,255,255,1)');
            gradient.addColorStop(0.1, 'rgba(170,248,255,0.3)');
            gradient.addColorStop(0.2, 'rgba(0,37,97,1)');
            gradient.addColorStop(1, 'rgba(0,0,0,1)');
            context.fillStyle = gradient;
            context.fillRect(0, 0, canvas.width, canvas.height);

            const texture = new THREE.Texture(canvas);
            texture.needsUpdate = true;
            return texture;


        function createPoints(geom) {
            const material = new THREE.PointsMaterial({
                color: 0xffffff,
                size: 3,
                transparent: true,
                blending: THREE.AdditiveBlending,
                map: generate(),//canvasをmapで渡す
                depthWrite: false

            const cloud = new THREE.Points(geom, material);
            return cloud;
        const geom = new THREE.TorusKnotGeometry(20, 6.9, 260, 11, 6, 3);
        const knot = createPoints(geom);

        // 毎フレーム時に実行されるループイベントです
        function tick() {

            knot.rotation.z += 0.001;
            knot.rotation.y += 0.001;

        webGLRenderer.render(scene, camera);// レンダリング