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

              
                
<p>マウスで動かしてみてね</p>
              
            
!

CSS

              
                
			body {
				background-color: #f0f0f0;
				color: #444;
			}
			a {
				color: #08f;
			}
              
            
!

JS

              
                console.log(THREE);

let camera, scene, renderer,loader;

init();

function init(){
        
        camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
				camera.position.set( 0, - 500, 900 );
        
				scene = new THREE.Scene();
				scene.background = new THREE.Color( 0xFADDE7 );

        //loder
        loader = new THREE.FontLoader();
        loader.load( 'https://threejs-plactice.vercel.app/fontloader/fonts/helvetiker_regular.typeface.json', function ( font ) {
          const color = 0xF09AB8;

					const matDark = new THREE.LineBasicMaterial( {
						color: color,
            opacity: 0.8,
						side: THREE.DoubleSide
					} );

					const matLite = new THREE.MeshBasicMaterial( {
            color: 0xFEFBFC,
						transparent: true,
						opacity: 1.0,
						side: THREE.DoubleSide
					} );
          const matDark2 = new THREE.MeshBasicMaterial( {
            color: 0x7D2844,
						transparent: true,
						opacity: 0.6,
						side: THREE.DoubleSide
					} );
        
   
          const message = '   Three.js\nSample';

					const shapes = font.generateShapes( message, 50 );

					const geometry = new THREE.ShapeGeometry( shapes );

					geometry.computeBoundingBox();

					const xMid = - 0.5 * ( geometry.boundingBox.max.x - geometry.boundingBox.min.x );

					geometry.translate( xMid, 0, 0 );
          const text = new THREE.Mesh( geometry, matLite );
					text.position.z = - 100;
          text.position.x = -100;
					scene.add( text );
          
          const text2 = new THREE.Mesh( geometry, matDark2 );
					text2.position.z = 100;
          text2.position.x = 100;
					scene.add( text2 );
          
          //hole
          const holeShapes = [];

					for ( let i = 0; i < shapes.length; i ++ ) {

						const shape = shapes[ i ];

						if ( shape.holes && shape.holes.length > 0 ) {

							for ( let j = 0; j < shape.holes.length; j ++ ) {

								const hole = shape.holes[ j ];
								holeShapes.push( hole );

							}

						}

					}
          shapes.push.apply( shapes, holeShapes );

					const lineText = new THREE.Object3D();

					for ( let i = 0; i < shapes.length; i ++ ) {

						const shape = shapes[ i ];

						const points = shape.getPoints();
						const geometry = new THREE.BufferGeometry().setFromPoints( points );

						geometry.translate( xMid, 0, 0 );

						const lineMesh = new THREE.Line( geometry, matDark );
						lineText.add( lineMesh );

					}

					scene.add( lineText );

					render();

          })
        renderer = new THREE.WebGLRenderer( { antialias: true } );
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				document.body.appendChild( renderer.domElement );

				const controls = new THREE.OrbitControls( camera, renderer.domElement );
				controls.target.set( 0, 0, 0 );
				controls.update();

				controls.addEventListener( 'change', render );

				window.addEventListener( 'resize', onWindowResize );
  
        tick();

 }
function onWindowResize() {

				camera.aspect = window.innerWidth / window.innerHeight;
				camera.updateProjectionMatrix();

				renderer.setSize( window.innerWidth, window.innerHeight );

				render();

			}

function render() {

  renderer.render( scene, camera );

}

function tick() {
  scene.rotation.x += 0.002;
  scene.rotation.z += 0.002;
  renderer.render(scene, camera);
  requestAnimationFrame(tick);
}
              
            
!
999px

Console