This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dx:Number = x2 - x1; | |
var dy:Number = y2 - y1; | |
var dist:Number = Math.sqrt(dx * dx + dy * dy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dx:Number = x2 - x1; | |
var dy:Number = y2 - y1; | |
var angle:Number = Math.atan2(dy, dx); // ラジアン |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// x = 底辺 | |
// y = 対辺 | |
// r = 斜辺 | |
// radian = 底辺、斜辺間の角度(ラジアン) | |
var x = r * Math.cos(radian); | |
var y = r * Math.sin(radian); | |
var r = x / Math.cos(radian); | |
var r = y / Math.sin(radian); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 目標値 | |
var t = 100; | |
// 現在値 | |
var val = 0; | |
function update() { | |
val += (t - val) * 0.5; | |
if(Math.abs(t - val) < 0.5) { | |
val = t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spring = 0.5; | |
var friction = 0.5; | |
var v = 0; | |
var t = 100; // 目標値 | |
var val = 0; // 現在値 | |
function update() { | |
v += (t - val) * spring; | |
val += (v *= friction); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// カメラ座標 | |
var cameraPos = new Vector3(); | |
// ステージ高さ | |
var stageHeight = 900; | |
// 度単位でのカメラの視野 | |
var fieldOfView = 45; | |
// ピクセル等倍になるカメラZ値 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scene.remove(mesh); | |
mesh.material.dispose(); | |
mesh.geometry.dispose(); | |
// テクスチャもう使わない場合は手動で破棄 | |
tex.dispose(); // or mesh.material.map.dispose(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// カメラ | |
var camera = new THREE.OrthographicCamera(); | |
// レンダラー | |
// id=mainのcanvasタグ指定 | |
var renderer = new THREE.WebGLRenderer({ | |
antialias: false, | |
canvas: document.getElementById('main') | |
}); | |
renderer.setPixelRatio(window.devicePixelRatio || 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geo = new THREE.BufferGeometry(); | |
geo.setIndex(new THREE.BufferAttribute(new Uint16Array(3 * 2), 1)); | |
geo.addAttribute('position', new THREE.BufferAttribute(new Float32Array(3 * 4), 3)); | |
geo.addAttribute('uv', new THREE.BufferAttribute(new Float32Array(2 * 4), 2)); | |
// サイズ | |
w = 1000; | |
h = 1000; | |
// 頂点インデックス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ball | |
constructor: -> | |
@radius = 0 | |
@x = 0 | |
@y = 0 | |
@vx = 0 | |
@vy = 0 | |
@mass = 1 |
OlderNewer