Skip to content

Instantly share code, notes, and snippets.

View gonchar's full-sized avatar

Sergey Gonchar gonchar

View GitHub Profile
@gonchar
gonchar / gist:3386564
Created August 18, 2012 12:24
Eclipse(FDT, FlashBuilder) Useful Alternativa3D Start Template with orbitCamera controller
package ${enclosing_package} {
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.Resource;
import alternativa.engine3d.core.View;
import alternativa.engine3d.materials.FillMaterial;
import alternativa.engine3d.objects.WireFrame;
import alternativa.engine3d.primitives.Box;
import flash.display.Sprite;
@gonchar
gonchar / gist:3386593
Created August 18, 2012 12:30
Useful Alternativa3D Start class with orbitCamera controller
package {
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.Resource;
import alternativa.engine3d.core.View;
import alternativa.engine3d.materials.FillMaterial;
import alternativa.engine3d.objects.WireFrame;
import alternativa.engine3d.primitives.Box;
import flash.display.Sprite;
@gonchar
gonchar / gist:4997713
Created February 20, 2013 18:18
Readback screenshot in Chrome PPAPI Flash Player Plugin
package com.realaxy.utils {
import alternativa.engine3d.core.Camera3D;
import flash.display.BitmapData;
import flash.display.Stage3D;
import flash.events.TimerEvent;
import flash.utils.Timer;
/**
* Readback screenshot in Chrome PPAPI Flash Player Plugin
@gonchar
gonchar / eventclasstemplate
Created March 5, 2013 17:35
EventClass template for FDT/FlashBuilder
package ${enclosing_package} {
import flash.events.Event;
public class ${enclosing_type} extends Event
{
public function ${enclosing_type}(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
@gonchar
gonchar / AwayTransform.as
Created December 25, 2013 13:51
Matrix3D class with clear API, direct access to the components, without unnecessary instance creation inside methods. But, it works a little bit slower than native Matrix3D methods.
package away3d.core.math {
import flash.geom.Matrix3D;
import flash.geom.Orientation3D;
import flash.geom.Vector3D;
public class AwayTransform {
public var a:Number = 1;
public var b:Number = 0;
public var c:Number = 0;
@gonchar
gonchar / ConditionTest.as
Created December 26, 2013 00:57
a||=new Object() a = a || new Object() if(!a) a = new Object();
package {
import flash.display.Sprite;
public class ConditionTest extends Sprite{
public function ConditionTest() {
}
private function func1():void {
var a:Sprite;
@gonchar
gonchar / ConditionTest.as
Created December 26, 2013 11:28
it's not about a deep optimization. That test shows you that you can freely write more readable code and it will be fast. the winner if(a == null) a = new Object(); don't use a||=new Object(); a = a || new Object(), because it looks like |\||\|\+_)+_)(_(*(^&(*&%&*^%$%^$ :D
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getTimer;
public class ConditionTest extends Sprite {
public function ConditionTest() {
testTime();
@gonchar
gonchar / trace
Created January 6, 2014 00:14
Trace for VisualStudio
#include <sstream>
#include <thread>
#include <cstdio>
#include <cstdarg>
#include <cwchar>
#include <cstdlib>
#include <windows.h>
struct DebugOutImpl {
DebugOutImpl(const char* location, int line, bool enabled_ = true)
@gonchar
gonchar / speedTest.cpp
Last active January 2, 2016 21:38
Crossbridge test
//
//
//Time:
//
//0.195312 - All browsers with FlashPlayer 11.9 release http://i.imgur.com/0WrbiVP.png
//0.203 - exe compiled with MSVC in release http://i.imgur.com/9aUm4TZ.png
//
//Download swf - https://www.dropbox.com/s/0vwvvo04d179gef/speedTest.swf
//
//Compile in Crossbridge /cygdrive/c/flascc/sdk/usr/bin/g++.exe speedTest.cpp -O4 -emit-swf -o speedTest.swf
@gonchar
gonchar / TextureGenerator.as
Last active August 29, 2015 13:56
generate orientation texture
public static function generateOrientationTexture(size:int):BitmapData {
var half:uint = size / 2;
var bmd:BitmapData = new BitmapData(size, size, false, 0x000000);
for (var i:uint = 0; i < size; i++) {
for (var j:uint = 0; j < size; j++) {
var directionX:Number = i - half;
var directionY:Number = j - half;
var length:Number = Math.sqrt(directionX * directionX + directionY * directionY);
directionX /= length;
directionY /= length;