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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>ジオメトリサンプル</title>
        <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r127/three.min.js"></script>
      <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/three@0.101.1/examples/js/controls/OrbitControls.js"></script>
        <script>
            // ページの読み込みを待つ
            window.addEventListener('load', init);
        
            function init() {
        
            
                // レンダラーを作成
                const renderer = new THREE.WebGLRenderer();
                renderer.setClearColor(new THREE.Color(0xFDFDFD));
                //sceneの大きさの通知
                renderer.setSize(window.innerWidth, window.innerHeight);
                renderer.setPixelRatio(window.devicePixelRatio);
            
            
                // シーンを作成
                const scene = new THREE.Scene();
            
                // カメラを作成
                const camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 1, 1000);
                camera.position.set(0, 0, 850);
               //カメラコントロール
                const controls = new THREE.OrbitControls(camera, document.body);

                // 滑らかにカメラコントローラーを制御する
                controls.enableDamping = true;
                controls.dampingFactor = 0.2;
              


                 // sphere(球)の作成(半径,水平セグメント数,垂直セグメント,書き始めの位置)
                const geometry = new THREE.SphereGeometry(80, 32, 32);
                const material = new THREE.MeshLambertMaterial({color:0xf21170,
                    opacity: 0.8,
                    transparent: true,
                    side: THREE.DoubleSide,});
                const sphere = new THREE.Mesh(geometry, material);
                scene.add(sphere);

                //箱の作成
                const geometrybox = new THREE.BoxGeometry(80, 80, 80 );
                const materialbox = new THREE.MeshLambertMaterial( {
                    color: 0x3edbf0,
                    opacity: 0.5,
                    transparent: true,
                    side: THREE.DoubleSide,});
                const cube = new THREE.Mesh( geometrybox, materialbox );
                scene.add(cube);

                cube.position.x = -150;
                cube.position.y = 150;
                cube.position.z = 0;

                // 平面の作成
                const planeGeometry = new THREE.PlaneGeometry(300, 200);
                const planeMaterial = new THREE.MeshToonMaterial({color: 0x6699FF}) 
                const plane = new THREE.Mesh(planeGeometry, planeMaterial);
                // planeの配置
                plane.rotation.y = 0.08 * Math.PI;
                plane.position.x = 300;
                plane.position.y = 100;
                plane.position.z = 0;

                scene.add(plane);

                //円錐 半径、高さ、円周の周りのセグメント数
                const conegeometry = new THREE.ConeGeometry( 60, 80, 100);
                const conematerial = new THREE.MeshPhongMaterial( {
                    color: 0xFF0000,
                    opacity: 0.8,
                    transparent: true,
                    side: THREE.DoubleSide,} );
                const cone = new THREE.Mesh( conegeometry, conematerial );
                cone.position.x = -300;
                cone.position.y = -200;
                cone.position.z = 0;
                scene.add( cone );

                //円柱 radiusTop(上面の半径), radiusBottom(底面の半径), height(高さ), radiusSegments(円周の分割数), heightSegments(高さの分割数), openEnded(ふた)
                const cylgeometry = new THREE.CylinderGeometry( 40, 40, 100, 100 );
                const cylmaterial = new THREE.MeshPhongMaterial( {
                    color: 0x00adb5,
                    opacity: 0.6,
                    transparent: true,
                } );
                const cylinder = new THREE.Mesh( cylgeometry, cylmaterial );
                cylinder.position.x = -300;
                cylinder.position.y = 200;
                cylinder.position.z = 0;
                cylinder.rotation.x = 10;
                scene.add( cylinder );

                 //円柱 応用 
                const cylgeometry2 = new THREE.CylinderGeometry( 40, -40, 100, 100 );
                const cylmaterial2 = new THREE.MeshToonMaterial( {
                    color: 0xFF0000,
                    opacity: 0.6,
                    transparent: true,
                    side: THREE.DoubleSide,
                } );
                const cylinder2 = new THREE.Mesh( cylgeometry2, cylmaterial2 );
                cylinder2.position.x = -400;
                cylinder2.position.y = 200;
                cylinder2.position.z = 0;
                cylinder2.rotation.x = 10;
                scene.add( cylinder2 );

                //ドーナッツ
                const torusgeometry = new THREE.TorusGeometry( 80, 30, 100, 100);
                const torusmaterial = new THREE.MeshToonMaterial( { 
                    color: 0x00adb5,
                    opacity: 0.6,
                    transparent: true,
                    side: THREE.DoubleSide,
                } );
                const torus = new THREE.Mesh( torusgeometry, torusmaterial );
                torus.position.x = 150;
                torus.position.y = -200;
                torus.position.z = 0;
                scene.add( torus );

                //結び目 radius(半径), tube(紐の太さ), radialSegments(長さの分割数・滑らかさ), tubularSegments(断面), p(巻き数), q(ひねり数), heightScale(Zの倍率)
                const knotgeometry = new THREE.TorusKnotGeometry( 40, 10, 100, 16);
                const knotmaterial = new THREE.MeshToonMaterial( {
                    color: 0xffff00,
                    opacity: 0.6,
                    transparent: true,
                    side: THREE.DoubleSide, } );
                const torusKnot = new THREE.Mesh( knotgeometry, knotmaterial );
                torusKnot.position.x = -150;
                torusKnot.position.y = -150;
                torusKnot.position.z = 0;
                scene.add( torusKnot );



                 //2次元の円  radius(半径), segments(角度の分割), thetaStart(開始角度), thetaLength(中心角度)
                const circlegeometry = new THREE.CircleGeometry( 100,10,0.3 * Math.PI * 2, 5.5);
                const circlematerial = new THREE.MeshLambertMaterial( { 
                    color: 0x6699FF,
                    opacity: 0.6,
                    side: THREE.DoubleSide,
                } );
                const circle = new THREE.Mesh( circlegeometry, circlematerial );
                //ワイヤーフレームのメッシュ作成
                const wire = new THREE.MeshBasicMaterial({color: 0xffffff, wireframe: true});
                const wiremesh = new THREE.Mesh(circlegeometry, wire);
                //配置
                circle.position.x = 350;
                circle.position.y = -150;
                circle.position.z = 0;
                wiremesh.position.x = 350;
                wiremesh.position.y = -150;
                wiremesh.position.z = 0;
                scene.add( circle );
                scene.add(wiremesh);

                // スポッドライト(色, 光の強さ, 距離, 照射角, ボケ具合, 減衰率)
                const spotLight = new THREE.SpotLight(0xffffff);
                spotLight.position.set( 100, 100, 450 );
                spotLight.castShadow = true;
                scene.add(spotLight);

                document.getElementById("myCanvas").appendChild(renderer.domElement);
            
                tick();
            
                // 毎フレーム時に実行されるループイベントです
                function tick() {
                  //  box.rotation.y += 0.01;
                    sphere.rotation.y += 0.01;
                    cube.rotation.x += 0.01;
                    cube.rotation.y += 0.01;
                    torus.rotation.y += 0.01; 
                    torusKnot.rotation.y += 0.01; 
                    circle.rotation.x += 0.01; 
                    wiremesh.rotation.x += 0.01; 
                    renderer.render(scene, camera); // レンダリング
            
                    requestAnimationFrame(tick);
                }
                }
            </script>
        <style>
            body {
                /* set margin to 0 and overflow to hidden, to go fullscreen */
                margin: 0;
            
            }

        </style>
    </head>
    <body>
        <div id="myCanvas">
        </div>
    </body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console