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

              
                <p class="hoge">
こいつが表示されるはず→
</p>
<div id="stage">
</div>


              
            
!

CSS

              
                body {
  overflow-x: hidden;
}
.hoge {
  text-align: center;
  padding: 10px 0;
}
#stats {
  position: absolute;
  top:0 ;
  left: 0;
}
              
            
!

JS

              
                $(window).on("load",function(){
  init();
});

var scene = new THREE.Scene();

//最初のドン
function init(){

  //カメラ作る
  var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
  camera.position.x = 0;
  camera.position.y = 0;
  camera.position.z = 20;
  camera.lookAt(scene.position);
  
  //レンダラー作る
  var renderer = new THREE.WebGLRenderer();
  renderer.setClearColor(new THREE.Color(0x000000));
  renderer.setSize(window.innerWidth, window.innerHeight);

  //axes 便利な座標を出してくれますよ
  var axes = new THREE.AxisHelper(20);
  scene.add(axes);

  //レンダラー追加
  $("#stage").append(renderer.domElement);


  //ステータス表示したかったらどうぞ
  var stats = new Stats();
  stats.setMode(0);
  $("#stats").append(stats.domElement);

  
  /*  メインの場所 ----------------------------------------------- */
  //THREE.Pointsに入れる ジオメトリ + マテリアルを準備
  //1.球ジオメトリ作成
  var geometry = new THREE.SphereGeometry(10,10,10);
  //2.球マテリアル、通称タマテリ
   var tamaterial = new THREE.PointsMaterial({
        color: 0xffffee,
        size: 3,
        transparent: true,
        blending: THREE.AdditiveBlending,
        map: get_canvasTexture(),//キャンバス作ってテクスチャに突っ込んだ子が帰ってくる
        depthWrite: false
   });
  var pointObject = new THREE.Points(geometry, tamaterial);
  pointObject.sortParticles = true;
  scene.add(pointObject);

  //レンダーは最後に入れないと表示されなのだよ困ったもんだ。。。
  renderer.render(scene, camera);
}

//作ったcanvasを返す
function get_canvasTexture(){
  
    var canvas = document.createElement('canvas');
    canvas.width = 16;
    canvas.height = 16;
    var context = canvas.getContext('2d');
    context.fillStyle = "rgb(200, 0, 0)";
    context.fillRect(0, 0, canvas.width, canvas.height);
  
    $(".hoge")[0].appendChild(canvas);
    var texture = new THREE.Texture(canvas);
    texture.needsUpdate = true;
    return texture;
}
              
            
!
999px

Console