Three.js

three.jsは、ウェブブラウザ上でリアルタイムレンダリングによる3次元コンピュータグラフィックスを描画する、クロス�…

Three.js
Three.js
Three.jsの例のスクリーンショット
作者 Ricardo Cabello (Mr.doob)
開発元 Three.js Authors[1]
初版 2010年4月24日 (2010-04-24)[2]
最新版 185[3] ウィキデータを編集 - 2026年6月25日 (58日前) [±]
リポジトリ ウィキデータを編集
プログラミング
言語
JavaScript
サイズ 409,474 KB, gzip: 98,706 KB[2]
サポート状況 アクティブ
種別 JavaScriptライブラリ
ライセンス MITライセンス[1]
公式サイト threejs.org ウィキデータを編集
テンプレートを表示

three.jsは、ウェブブラウザ上でリアルタイムレンダリングによる3次元コンピュータグラフィックスを描画する、クロスブラウザ対応の軽量なJavaScriptライブラリおよびAPIである。

HTML5canvas要素Scalable Vector GraphicsWebGLとの組み合わせが可能である。ソースコードGitHubでホストされている。

WebGLというWeb標準技術の登場により[4]、商用のブラウザ拡張機能に頼らずに、HTMLファイル内に埋め込まれたJavaScriptを介して、GPUアクセラレーションによる動的表現を描画することが可能になった[5][6]。three.jsは、WebGLのAPIを簡略化するためのラッパである。

ライブラリは単一のJavaScriptファイルであり、以下のようにHTML内でローカルやリモートコピーにリンクすることで動作する。

<script src="js/three.min.js"></script>

以下のコードはdocument.body要素内に、画面上にカメラ、XY軸で回転する立方体、WebGL描画表示域を追加する。

<script>

    var camera, scene, renderer,
    geometry, material, mesh;

    init();
    animate();

    function init() {
        scene = new THREE.Scene();

        camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
        camera.position.z = 1000;

        geometry = new THREE.BoxGeometry( 200, 200, 200 );
        material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );

        mesh = new THREE.Mesh( geometry, material );
        scene.add( mesh );

        renderer = new THREE.WebGLRenderer();
        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild( renderer.domElement );
    }

    function animate() {
        requestAnimationFrame( animate );
        render();
    }

    function render() {
        mesh.rotation.x += 0.01;
        mesh.rotation.y += 0.02;

        renderer.render( scene, camera );
    }

</script>

脚注

  1. ^ a b Three.js/license”. github.com/mrdoob. 2012年5月20日閲覧。
  2. ^ a b Three.js/readme.md”. github.com/mrdoob. 2012年5月20日閲覧。
  3. ^ Release 185” (2026年6月25日). 2026年6月25日閲覧。
  4. ^ “Khronos Releases Final WebGL 1.0 Specification”. Khronos Group. March 3, 2011. 2012年6月2日閲覧.
  5. ^ O3D英語版
  6. ^ Unity

外部リンク

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.