|
@@ -115,12 +115,43 @@ class Material extends Prefab {
|
|
mat.mainPass.setPassName(mainPassName);
|
|
mat.mainPass.setPassName(mainPassName);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override function makeInstance() {
|
|
|
|
+ #if editor
|
|
|
|
+ var mats = getMaterials();
|
|
|
|
+
|
|
|
|
+ if ( mats == null || mats.length == 0 ) {
|
|
|
|
+ if (previewSphere != null)
|
|
|
|
+ throw "what";
|
|
|
|
+
|
|
|
|
+ var parent = findFirstLocal3d();
|
|
|
|
+
|
|
|
|
+ var sphere = new h3d.prim.Sphere(1., 64, 48);
|
|
|
|
+ sphere.addUVs();
|
|
|
|
+ sphere.addNormals();
|
|
|
|
+ sphere.addTangents();
|
|
|
|
+ sphere.colors = sphere.points;
|
|
|
|
+
|
|
|
|
+ var m = new h3d.scene.Mesh(sphere);
|
|
|
|
+ m.name = "previewSphereObjName";
|
|
|
|
+ @:privateAccess m.material.name = "previewMat";
|
|
|
|
+ previewSphere = m;
|
|
|
|
+ parent.addChild(previewSphere);
|
|
|
|
+
|
|
|
|
+ var previewCount = findFirstLocal3d().getScene().findAll(o -> o.name == "previewSphereObjName" ? true : null).length;
|
|
|
|
+ previewSphere.x = ( previewCount - 1) * 5.0;
|
|
|
|
+ }
|
|
|
|
+ #end
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ updateInstance();
|
|
|
|
+ }
|
|
|
|
+
|
|
override function updateInstance(?propName ) {
|
|
override function updateInstance(?propName ) {
|
|
var local3d = findFirstLocal3d();
|
|
var local3d = findFirstLocal3d();
|
|
if( local3d == null )
|
|
if( local3d == null )
|
|
return;
|
|
return;
|
|
|
|
|
|
- var mats = getMaterials();
|
|
|
|
|
|
+ var mats = getMaterials(true);
|
|
|
|
|
|
if (this.refMatLib != null && this.refMatLib != "") {
|
|
if (this.refMatLib != null && this.refMatLib != "") {
|
|
// We want to save some infos to reapply them after loading datas from the choosen mat
|
|
// We want to save some infos to reapply them after loading datas from the choosen mat
|
|
@@ -153,31 +184,6 @@ class Material extends Prefab {
|
|
|
|
|
|
var props = renderProps();
|
|
var props = renderProps();
|
|
|
|
|
|
- #if editor
|
|
|
|
- if ( mats == null || mats.length == 0 ) {
|
|
|
|
- if (previewSphere != null)
|
|
|
|
- previewSphere.remove();
|
|
|
|
-
|
|
|
|
- var parent = findFirstLocal3d();
|
|
|
|
-
|
|
|
|
- var sphere = new h3d.prim.Sphere(1., 64, 48);
|
|
|
|
- sphere.addUVs();
|
|
|
|
- sphere.addNormals();
|
|
|
|
- sphere.addTangents();
|
|
|
|
- sphere.colors = sphere.points;
|
|
|
|
-
|
|
|
|
- var m = new h3d.scene.Mesh(sphere);
|
|
|
|
- m.name = "previewSphereObjName";
|
|
|
|
- @:privateAccess m.material.name = "previewMat";
|
|
|
|
- previewSphere = m;
|
|
|
|
- parent.addChild(previewSphere);
|
|
|
|
-
|
|
|
|
- var previewCount = findFirstLocal3d().getScene().findAll(o -> o.name == "previewSphereObjName" ? true : null).length;
|
|
|
|
- previewSphere.x = ( previewCount - 1) * 5.0;
|
|
|
|
-
|
|
|
|
- mats = [ @:privateAccess m.material ];
|
|
|
|
- }
|
|
|
|
- #end
|
|
|
|
function loadTextureCb( path : String ) : h3d.mat.Texture {
|
|
function loadTextureCb( path : String ) : h3d.mat.Texture {
|
|
return shared.loadTexture(path, false);
|
|
return shared.loadTexture(path, false);
|
|
}
|
|
}
|
|
@@ -185,10 +191,6 @@ class Material extends Prefab {
|
|
update(m, props, loadTextureCb);
|
|
update(m, props, loadTextureCb);
|
|
}
|
|
}
|
|
|
|
|
|
- override function makeInstance() {
|
|
|
|
- updateInstance();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
function applyOverrides() {
|
|
function applyOverrides() {
|
|
if (this.overrides == null || this.overrides.length == 0)
|
|
if (this.overrides == null || this.overrides.length == 0)
|
|
return;
|
|
return;
|
|
@@ -225,6 +227,15 @@ class Material extends Prefab {
|
|
}
|
|
}
|
|
|
|
|
|
#if editor
|
|
#if editor
|
|
|
|
+ override function makeInteractive() : hxd.SceneEvents.Interactive {
|
|
|
|
+ if (previewSphere != null) {
|
|
|
|
+ var col = new h3d.col.Sphere(0,0,0,1.);
|
|
|
|
+ var int = new h3d.scene.Interactive(col, previewSphere);
|
|
|
|
+ return int;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
override function edit( ctx : hide.prefab.EditContext ) {
|
|
override function edit( ctx : hide.prefab.EditContext ) {
|
|
super.edit(ctx);
|
|
super.edit(ctx);
|
|
|
|
|