|
@@ -17,6 +17,11 @@ class Scene extends Component implements h3d.IDrawable {
|
|
canvas = cast new Element("<canvas class='hide-scene' style='width:100%;height:100%'/>").appendTo(root)[0];
|
|
canvas = cast new Element("<canvas class='hide-scene' style='width:100%;height:100%'/>").appendTo(root)[0];
|
|
canvas.addEventListener("mousemove",function(_) canvas.focus());
|
|
canvas.addEventListener("mousemove",function(_) canvas.focus());
|
|
canvas.addEventListener("mouseleave",function(_) canvas.blur());
|
|
canvas.addEventListener("mouseleave",function(_) canvas.blur());
|
|
|
|
+ canvas.oncontextmenu = function(e){
|
|
|
|
+ e.stopPropagation();
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
haxe.Timer.delay(delayedInit,0); // wait canvas added to window
|
|
haxe.Timer.delay(delayedInit,0); // wait canvas added to window
|
|
}
|
|
}
|
|
|
|
|
|
@@ -64,19 +69,56 @@ class Scene extends Component implements h3d.IDrawable {
|
|
engine.render(this);
|
|
engine.render(this);
|
|
}
|
|
}
|
|
|
|
|
|
- public function loadTextureFile( path : String, onReady : h3d.mat.Texture -> Void ) {
|
|
|
|
|
|
+ public function loadTexture( path : String, onReady : h3d.mat.Texture -> Void, ?target : h3d.mat.Texture ) {
|
|
var path = ide.getPath(path);
|
|
var path = ide.getPath(path);
|
|
var img = new Element('<img src="file://$path"/>');
|
|
var img = new Element('<img src="file://$path"/>');
|
|
img.on("load",function() {
|
|
img.on("load",function() {
|
|
setCurrent();
|
|
setCurrent();
|
|
var bmp : js.html.ImageElement = cast img[0];
|
|
var bmp : js.html.ImageElement = cast img[0];
|
|
- var t = new h3d.mat.Texture(bmp.width, bmp.height);
|
|
|
|
|
|
+ var t;
|
|
|
|
+ if( target == null )
|
|
|
|
+ t = new h3d.mat.Texture(bmp.width, bmp.height);
|
|
|
|
+ else {
|
|
|
|
+ t = target;
|
|
|
|
+ target.resize(bmp.width, bmp.height);
|
|
|
|
+ }
|
|
untyped bmp.ctx = { getImageData : function(_) return bmp, canvas : { width : 0, height : 0 } };
|
|
untyped bmp.ctx = { getImageData : function(_) return bmp, canvas : { width : 0, height : 0 } };
|
|
engine.driver.uploadTextureBitmap(t, cast bmp, 0, 0);
|
|
engine.driver.uploadTextureBitmap(t, cast bmp, 0, 0);
|
|
onReady(t);
|
|
onReady(t);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function loadModel( path : String ) {
|
|
|
|
+ var lib = loadHMD(path,false);
|
|
|
|
+ return lib.makeObject(loadHMDTexture.bind(path));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function loadHMDTexture( basePath : String, texturePath : String ) {
|
|
|
|
+ if( sys.FileSystem.exists(texturePath) ) {
|
|
|
|
+ var t = new h3d.mat.Texture(1,1);
|
|
|
|
+ t.clear(0x102030);
|
|
|
|
+ loadTexture(texturePath, function(_) {}, t);
|
|
|
|
+ return t;
|
|
|
|
+ }
|
|
|
|
+ trace("TODO:",basePath, texturePath);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function loadHMD( path : String, isAnimation : Bool ) {
|
|
|
|
+ var fullPath = ide.getPath(path);
|
|
|
|
+ var data = sys.io.File.getBytes(fullPath);
|
|
|
|
+ if( data.get(0) != 'H'.code ) {
|
|
|
|
+ var hmdOut = new hxd.fmt.fbx.HMDOut();
|
|
|
|
+ hmdOut.absoluteTexturePath = true;
|
|
|
|
+ hmdOut.loadTextFile(data.toString());
|
|
|
|
+ var hmd = hmdOut.toHMD(null, !isAnimation);
|
|
|
|
+ var out = new haxe.io.BytesOutput();
|
|
|
|
+ new hxd.fmt.hmd.Writer(out).write(hmd);
|
|
|
|
+ data = out.getBytes();
|
|
|
|
+ }
|
|
|
|
+ return hxd.res.Any.fromBytes(path,data).toModel().toHmd();
|
|
|
|
+ }
|
|
|
|
+
|
|
public function render( e : h3d.Engine ) {
|
|
public function render( e : h3d.Engine ) {
|
|
s3d.render(e);
|
|
s3d.render(e);
|
|
s2d.render(e);
|
|
s2d.render(e);
|