Kaynağa Gözat

Samples: fix compilation

Yuxiao Mao 5 ay önce
ebeveyn
işleme
cec15b8f2f

+ 3 - 1
h2d/domkit/Style.hx

@@ -566,11 +566,13 @@ class Style extends domkit.CssStyle {
 					var f = find(files, f -> f.name == vs.pos.file);
 					if (f != null) {
 						var res = find(resources, r -> r.name == f.name);
-						var entry = Std.downcast(res?.entry, hxd.fs.LocalFileSystem.LocalEntry);
 						var resDir = "";
+						#if (sys || nodejs)
+						var entry = Std.downcast(res?.entry, hxd.fs.LocalFileSystem.LocalEntry);
 						if (entry != null && @:privateAccess entry.file.lastIndexOf("/") > 0) {
 							resDir = @:privateAccess entry.file.substr(0, entry.file.lastIndexOf("/"));
 						}
+						#end
 						var pos = getPos(f, vs.pos.pmin);
 						var s = "" + pos.line;
 						if (pos.file == null)

+ 1 - 1
h3d/mat/PbrMaterialSetup.hx

@@ -25,7 +25,7 @@ class PbrMaterialSetup extends MaterialSetup {
 		return @:privateAccess new PbrMaterial();
 	}
 
-	#if hide
+	#if (hide && nodejs)
 	public function createModelLibShader() {
 		return new hrt.prefab.l3d.ModelLibrary.ModelLibShader();
 	}

+ 12 - 12
samples/FxView.hx

@@ -21,26 +21,26 @@ class FxView extends hxd.App {
 		var prefab = hxd.Res.hideEffect.load();
 		var unk = prefab.getOpt(hrt.prefab.Unknown);
 		if( unk != null )
-			throw "Prefab "+unk.getPrefabType()+" was not compiled";
+			throw "Prefab "+unk.type+" was not compiled";
 
-		var ctx = new hrt.prefab.Context();
-		var shared = new hrt.prefab.ContextShared();
-		ctx.shared = shared;
-		shared.root2d = s2d;
-		shared.root3d = s3d;
-		ctx.init();
+		var ctx = new hrt.prefab.ContextShared(s2d, s3d);
 
 		function play() {
 			var i = prefab.make(ctx);
-			var fx = cast(i.local3d, hrt.prefab.fx.FX.FXAnimation);
-			fx.onEnd = function() {
-				fx.remove();
-				play();
-			};
+			var obj = i.to(hrt.prefab.Object3D);
+			if( obj != null ) {
+				var fx = cast(obj.local3d, hrt.prefab.fx.FX.FXAnimation);
+				fx.onEnd = function() {
+					fx.remove();
+					play();
+				};
+			}
 		}
 		play();
 
 		new h3d.scene.CameraController(20,s3d);
+		var text = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
+		text.text = "Drag and move with your mouse!";
 
 	}
 

+ 6 - 4
samples/Lights.hx

@@ -45,8 +45,9 @@ class Lights extends SampleApp {
 		box.addNormals();
 		for( i in 0...50 ) {
 			var m = new h3d.scene.Mesh(box, s3d);
-			m.material.color.set(Math.random(), Math.random(), Math.random());
-			m.material.color.normalize3();
+			var color = new h3d.Vector(Math.random(), Math.random(), Math.random());
+			color.normalize();
+			m.material.color.set(color.x, color.y, color.z);
 			m.scale(1 + Math.random() * 10);
 			m.z = m.scaleX * 0.5;
 			m.setRotation(0,0,Math.random() * Math.PI * 2);
@@ -64,8 +65,9 @@ class Lights extends SampleApp {
 		sp.addNormals();
 		for( i in 0...20 ) {
 			var m = new h3d.scene.Mesh(sp, s3d);
-			m.material.color.set(Math.random(), Math.random(), Math.random());
-			m.material.color.normalize3();
+			var color = new h3d.Vector(Math.random(), Math.random(), Math.random());
+			color.normalize();
+			m.material.color.set(color.x, color.y, color.z);
 			m.scale(0.5 + Math.random() * 4);
 			m.z = 2 + Math.random() * 5;
 			var cx = (Math.random() - 0.5) * 20;

+ 1 - 1
samples/MeshBatch.hx

@@ -71,7 +71,7 @@ class MeshBatch extends hxd.App {
 			batch.y = m.y;
 			batch.setScale(m.scale);
 			batch.setRotation(0,0,m.rot);
-			shader.color.load(m.color.toVector());
+			shader.color.set(m.color.x, m.color.y, m.color.z);
 			batch.emitInstance();
 		}
 	}

+ 1 - 1
samples/Sao.hx

@@ -25,7 +25,7 @@ class CustomRenderer extends h3d.scene.fwd.Renderer {
 		allPasses.push(mrt);
 	}
 
-	override function renderPass(p:h3d.pass.Base, passes, ?sort) {
+	override function renderPass(p:h3d.pass.Output, passes, ?sort) {
 		bench.measure(p.name);
 		return super.renderPass(p, passes, sort);
 	}

+ 2 - 2
samples/Video.hx

@@ -13,9 +13,9 @@ class Video extends hxd.App {
 		};
 		function start() {
 			#if hl
-			video.load("testVideo.avi");
+			video.loadFile("testVideo.avi");
 			#elseif js
-			video.load("testVideo.mp4");
+			video.loadFile("testVideo.mp4");
 			#end
 		}
 		video.onEnd = start;