Skip to content

Instantly share code, notes, and snippets.

View yomotsu's full-sized avatar

Akihiro Oyamada yomotsu

View GitHub Profile
@yomotsu
yomotsu / gist:11174945
Created April 22, 2014 11:25
toNumber
var toNumber = function ( text ) {
var i, charCode, charArray = [];
if ( typeof( text ) === 'number' && !isNaN( text ) ) {
return text;
}
text = text.replace( /,/, '' );
for ( i = text.length - 1; 0 <= i; i-- ) {
charCode = charArray[i] = text.charCodeAt( i );
switch( true ) {
case ( charCode <= 0xff5e && 0xff01 <= charCode ):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<svg viewBox="0 0 200 200" width="200" height="200">
@yomotsu
yomotsu / collision detection for Sphere vs Triangle in three.js
Created June 24, 2014 14:51
collision detection for Sphere vs Triangle in three.js
// collision detection for Sphere vs Triangle in three.js
// http://realtimecollisiondetection.net/blog/?p=103
var detectSphereVsTriangleCollision = function ( face, position, radius ) {
var A = new THREE.Vector3(),
B = new THREE.Vector3(),
C = new THREE.Vector3(),
rr,
V = new THREE.Vector3(),
@yomotsu
yomotsu / gist:2a9163ee9e1558135779
Created August 20, 2014 17:01
performance for threejs
new THREE.WebGLRenderer({ precision: "mediump", devicePixelRatio:1, antialias:false });
<a href="http://twitter.com/home?status=<?php echo urlencode(the_title_attribute('echo=0')); ?>%20<?php the_permalink(); ?>%20by%20@helloooo">
Twitter
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">
Facebook
</a>
<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>">
Google+
@yomotsu
yomotsu / gist:987f52d073cb54b4eb6b
Last active August 29, 2015 14:05
make a boundingSphere and boundingBox for a triangle
'use strict';
var triangle = {}
triangle.makeBoundingBox = function ( triangle ) {
var bb = new THREE.Box3();
bb.min = bb.min.min( triangle.a );
bb.min = bb.min.min( triangle.b );
var A = function () {
this.a = 1;
}
A.prototype.aaa = function () {
var count = 0;
return function () {
count ++;
console.log( this.a + count );
}
@yomotsu
yomotsu / gist:eb5bcf57cbf7c886bf21
Last active August 29, 2015 14:06
getMortonOrder
// based on http://marupeke296.com/COL_3D_No15_Octree.html
//
// +------+------+
// |\ 6 \ 7 \
// | +------+------+
// + |\ \ \
// |\| +------+------+
// |4+ | | |
// + |\| 2 | 3 |
// \| +------+------+
.PREFIX-block .PREFIX-block--element{
@at-root .PREFIX-block--modifier#{&} .PREFIX-block--elementElement{
color: red;
}
}
will be
.PREFIX-block--modifier.PREFIX-block .PREFIX-block--element .PREFIX-block--elementElement {
color: red; }
@yomotsu
yomotsu / gist:fe8d3a63f907a219cba0
Created September 5, 2014 15:10
boundingBox and boundingSphere for triangle
var triangle = {}
triangle.makeBoundingBox = function ( triangle ) {
var bb = new THREE.Box3();
bb.min = bb.min.min( triangle.a );
bb.min = bb.min.min( triangle.b );
bb.min = bb.min.min( triangle.c );