WebGLがノータイムで使えるenchant.jsの拡張プラグイン、gl.enchant.jsのβ版がついに完成したぞ!例えば球を出して回転させるプログラムは↓のような感じだ。
enchant(); var game; window.onload = function(){ game = new Game(320, 320); game.fps = 60; game.onload = function(){ var scene = new Scene3D(); //3Dシーンを作る scene.setDirectionalLight(new DirectionalLight()); //ライトを設置する var camera = new Camera3D(); //カメラを設置する scene.setCamera(camera); var ball = new Sphere(); //球を作る ball.texture = new Texture("../../images/enchant-sphere.png"); //テクスチャを読み込む ball.z =-10; ball.rotX = 0; ball.addEventListener('enterframe', function(e){ this.rotX += 0.01; this.rotation = [ //回転行列を設定して回転する Math.cos(this.rotX), 0, -Math.sin(this.rotX), 0, 0, 1, 0, 0, Math.sin(this.rotX), 0, Math.cos(this.rotX), 0, 0, 0, 0, 1 ]; }); scene.addChild(ball); //3Dシーンにボールを追加 }; game.start(); };
WebGLがノータイムで使えるenchant.jsの拡張プラグイン、gl.enchant.jsのβ版がついに完成したぞ!例えば球を出して回転させるプログラムは↓のような感じだ。
3D野郎は寄ってたかれ!WebGLでグリグリ遊べるgl.enchant.jsがついにβ公開!
http://wise9.jp/archives/6245enchant();
var game;
window.onload = function(){
game = new Game(320, 320);
game.fps = 60;
game.onload = function(){
var scene = new Scene3D(); //3Dシーンを作る
scene.setDirectionalLight(new DirectionalLight()); //ライトを設置する
var camera = new Camera3D(); //カメラを設置する
scene.setCamera(camera);
var ball = new Sphere(); //球を作る
ball.texture = new Texture("../../images/enchant-sphere.png"); //テクスチャを読み込む
ball.z =-10;
ball.rotX = 0;
ball.addEventListener('enterframe', function(e){
this.rotX += 0.01;
this.rotation = [ //回転行列を設定して回転する
Math.cos(this.rotX), 0, -Math.sin(this.rotX), 0,
0, 1, 0, 0,
Math.sin(this.rotX), 0, Math.cos(this.rotX), 0,
0, 0, 0, 1
];
});
scene.addChild(ball); //3Dシーンにボールを追加
};
game.start();
};
9leap : gl.enchant.js β版 by enchant_js - どこでも遊べる、投稿型ゲームサイト
http://9leap.net/games/1109/gl.enchant.js で初音ミク(はちゅね)を表示してみた - 強火で進め
http://d.hatena.ne.jp/nakamura001/20120118/1326904934関連するトピックス