mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-05-10 11:31:39 +00:00
make compatible with latest heaps repo
This commit is contained in:
parent
23e6417271
commit
9f777dd741
8 changed files with 49 additions and 53 deletions
|
|
@ -808,7 +808,7 @@ class DtsObject extends GameObject {
|
||||||
var prim:DynamicPolygon = cast mesh.primitive;
|
var prim:DynamicPolygon = cast mesh.primitive;
|
||||||
var vbuffer:FloatBuffer = null;
|
var vbuffer:FloatBuffer = null;
|
||||||
if (prim.buffer != null) {
|
if (prim.buffer != null) {
|
||||||
vbuffer = prim.getBuffer(prim.points.length);
|
vbuffer = prim.getDrawBuffer(prim.points.length);
|
||||||
}
|
}
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
for (i in info.indices) {
|
for (i in info.indices) {
|
||||||
|
|
@ -825,7 +825,7 @@ class DtsObject extends GameObject {
|
||||||
prim = cast mesh.primitive;
|
prim = cast mesh.primitive;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
if (prim.buffer != null) {
|
if (prim.buffer != null) {
|
||||||
vbuffer = prim.getBuffer(prim.points.length);
|
vbuffer = prim.getDrawBuffer(prim.points.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var vertex = info.vertices[i];
|
var vertex = info.vertices[i];
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ class DynamicPolygon extends MeshPrimitive {
|
||||||
indexes = h3d.Indexes.alloc(idx);
|
indexes = h3d.Indexes.alloc(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBuffer(vertices:Int) {
|
public function getDrawBuffer(vertices:Int) {
|
||||||
if (vbuf == null)
|
if (vbuf == null)
|
||||||
vbuf = hxd.impl.Allocator.get().allocFloats(vertices * 8)
|
vbuf = hxd.impl.Allocator.get().allocFloats(vertices * 8)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
|
#if js
|
||||||
import fs.ManifestFileSystem;
|
import fs.ManifestFileSystem;
|
||||||
|
import fs.ManifestBuilder;
|
||||||
|
#end
|
||||||
import hxd.Timer;
|
import hxd.Timer;
|
||||||
import hxd.Window;
|
import hxd.Window;
|
||||||
import src.AudioManager;
|
import src.AudioManager;
|
||||||
|
|
@ -11,7 +14,6 @@ import gui.MainMenuGui;
|
||||||
import hxd.res.DefaultFont;
|
import hxd.res.DefaultFont;
|
||||||
import h2d.Text;
|
import h2d.Text;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
import fs.ManifestBuilder;
|
|
||||||
|
|
||||||
class Main extends hxd.App {
|
class Main extends hxd.App {
|
||||||
var marbleGame:MarbleGame;
|
var marbleGame:MarbleGame;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class MarbleGame {
|
||||||
canvasElement.style.width = "100%";
|
canvasElement.style.width = "100%";
|
||||||
canvasElement.style.height = "100%";
|
canvasElement.style.height = "100%";
|
||||||
});
|
});
|
||||||
|
var canvas = js.Browser.document.getElementById("webgl");
|
||||||
var pointercontainer = js.Browser.document.querySelector("#pointercontainer");
|
var pointercontainer = js.Browser.document.querySelector("#pointercontainer");
|
||||||
pointercontainer.addEventListener('mousedown', (e:js.html.MouseEvent) -> {
|
pointercontainer.addEventListener('mousedown', (e:js.html.MouseEvent) -> {
|
||||||
var buttonCode = switch (e.button) {
|
var buttonCode = switch (e.button) {
|
||||||
|
|
@ -81,6 +82,31 @@ class MarbleGame {
|
||||||
var buttonCode = (e.keyCode);
|
var buttonCode = (e.keyCode);
|
||||||
@:privateAccess Key.keyPressed[buttonCode] = -Key.getFrame();
|
@:privateAccess Key.keyPressed[buttonCode] = -Key.getFrame();
|
||||||
});
|
});
|
||||||
|
js.Browser.window.addEventListener('keydown', (e:js.html.KeyboardEvent) -> {
|
||||||
|
var buttonCode = (e.keyCode);
|
||||||
|
@:privateAccess Key.keyPressed[buttonCode] = Key.getFrame();
|
||||||
|
});
|
||||||
|
js.Browser.window.addEventListener('keyup', (e:js.html.KeyboardEvent) -> {
|
||||||
|
var buttonCode = (e.keyCode);
|
||||||
|
@:privateAccess Key.keyPressed[buttonCode] = -Key.getFrame();
|
||||||
|
});
|
||||||
|
|
||||||
|
pointercontainer.addEventListener('touchstart', (e:js.html.TouchEvent) -> {
|
||||||
|
@:privateAccess Key.keyPressed[Key.MOUSE_LEFT] = Key.getFrame();
|
||||||
|
@:privateAccess scene2d.window.curMouseX = e.touches[0].clientX;
|
||||||
|
@:privateAccess scene2d.window.curMouseY = e.touches[0].clientY;
|
||||||
|
});
|
||||||
|
|
||||||
|
pointercontainer.addEventListener('touchend', (e:js.html.TouchEvent) -> {
|
||||||
|
@:privateAccess Key.keyPressed[Key.MOUSE_LEFT] = -Key.getFrame();
|
||||||
|
@:privateAccess scene2d.window.curMouseX = e.touches[0].clientX;
|
||||||
|
@:privateAccess scene2d.window.curMouseY = e.touches[0].clientY;
|
||||||
|
});
|
||||||
|
|
||||||
|
pointercontainer.addEventListener('touchmove', (e:js.html.TouchEvent) -> {
|
||||||
|
@:privateAccess scene2d.window.curMouseX = e.touches[0].clientX;
|
||||||
|
@:privateAccess scene2d.window.curMouseY = e.touches[0].clientY;
|
||||||
|
});
|
||||||
|
|
||||||
js.Browser.window.addEventListener('contextmenu', (e) -> e.preventDefault()); // Disable right click context menu for good
|
js.Browser.window.addEventListener('contextmenu', (e) -> e.preventDefault()); // Disable right click context menu for good
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,9 @@ class MarbleWorld extends Scheduler {
|
||||||
var sunDirection = MisParser.parseVector3(sunElement.direction);
|
var sunDirection = MisParser.parseVector3(sunElement.direction);
|
||||||
sunDirection.x = -sunDirection.x;
|
sunDirection.x = -sunDirection.x;
|
||||||
// sunDirection.z = -sunDirection.z;
|
// sunDirection.z = -sunDirection.z;
|
||||||
|
var ls = cast(scene.lightSystem, h3d.scene.fwd.LightSystem);
|
||||||
|
|
||||||
scene.lightSystem.ambientLight.load(ambientColor);
|
ls.ambientLight.load(ambientColor);
|
||||||
|
|
||||||
var shadow = scene.renderer.getPass(h3d.pass.DefaultShadowMap);
|
var shadow = scene.renderer.getPass(h3d.pass.DefaultShadowMap);
|
||||||
shadow.power = 0.5;
|
shadow.power = 0.5;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
#if js
|
||||||
import fs.ManifestLoader;
|
import fs.ManifestLoader;
|
||||||
import fs.ManifestBuilder;
|
import fs.ManifestBuilder;
|
||||||
|
import fs.ManifestProgress;
|
||||||
|
#end
|
||||||
import hxd.res.Image;
|
import hxd.res.Image;
|
||||||
import hxd.res.Sound;
|
import hxd.res.Sound;
|
||||||
import h3d.mat.Texture;
|
import h3d.mat.Texture;
|
||||||
|
|
@ -12,7 +15,6 @@ import dif.Dif;
|
||||||
import hxd.fs.LocalFileSystem;
|
import hxd.fs.LocalFileSystem;
|
||||||
import hxd.fs.FileSystem;
|
import hxd.fs.FileSystem;
|
||||||
import hxd.res.Loader;
|
import hxd.res.Loader;
|
||||||
import fs.ManifestProgress;
|
|
||||||
import src.Resource;
|
import src.Resource;
|
||||||
|
|
||||||
class ResourceLoader {
|
class ResourceLoader {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
package fs;
|
package fs;
|
||||||
|
|
||||||
|
import hxd.fs.FileInput;
|
||||||
import hxd.net.BinaryLoader;
|
import hxd.net.BinaryLoader;
|
||||||
import hxd.impl.ArrayIterator;
|
import hxd.impl.ArrayIterator;
|
||||||
import hxd.fs.LoadedBitmap;
|
import hxd.fs.LoadedBitmap;
|
||||||
|
|
@ -80,53 +81,17 @@ class ManifestEntry extends FileEntry {
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override function readBytes(out:haxe.io.Bytes, outPos:Int, pos:Int, len:Int):Int {
|
||||||
|
if (pos + len > bytes.length)
|
||||||
|
len = bytes.length - pos;
|
||||||
|
if (len < 0)
|
||||||
|
len = 0;
|
||||||
|
out.blit(outPos, bytes, pos, len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
override public function open() {
|
override public function open() {
|
||||||
#if sys
|
return @:privateAccess new FileInput(this);
|
||||||
if (fio == null)
|
|
||||||
fio = sys.io.File.read(file);
|
|
||||||
else
|
|
||||||
fio.seek(0, SeekBegin);
|
|
||||||
#else
|
|
||||||
readPos = 0;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function skip(nbytes:Int) {
|
|
||||||
#if sys
|
|
||||||
fio.seek(nbytes, SeekCur);
|
|
||||||
#else
|
|
||||||
readPos += nbytes;
|
|
||||||
if (bytes.length < readPos)
|
|
||||||
readPos = bytes.length;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function readByte():Int {
|
|
||||||
#if sys
|
|
||||||
return fio.readByte();
|
|
||||||
#else
|
|
||||||
return bytes.get(readPos++);
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function read(out:Bytes, pos:Int, size:Int) {
|
|
||||||
#if sys
|
|
||||||
fio.readFullBytes(out, pos, size);
|
|
||||||
#else
|
|
||||||
out.blit(pos, bytes, readPos, size);
|
|
||||||
readPos += size;
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function close() {
|
|
||||||
#if sys
|
|
||||||
if (fio != null) {
|
|
||||||
fio.close();
|
|
||||||
fio = null;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
readPos = 0;
|
|
||||||
#end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fancyLoad(onReady:() -> Void, onProgress:(cur:Int, max:Int) -> Void) {
|
public function fancyLoad(onReady:() -> Void, onProgress:(cur:Int, max:Int) -> Void) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package shaders;
|
package shaders;
|
||||||
|
|
||||||
import h3d.scene.Light;
|
import h3d.scene.fwd.Light;
|
||||||
|
|
||||||
class DirLight extends Light {
|
class DirLight extends Light {
|
||||||
var dshader:DirLightShader;
|
var dshader:DirLightShader;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue