|
@@ -4,4 +4,31 @@ package hrt.impl;
|
|
abstract TextureType(String) from String to String {
|
|
abstract TextureType(String) from String to String {
|
|
var gradient;
|
|
var gradient;
|
|
var path; // Not used as a type inside the json (the playload is a string), default value
|
|
var path; // Not used as a type inside the json (the playload is a string), default value
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+class Utils {
|
|
|
|
+ public static function getTextureFromValue(val : Any) : h3d.mat.Texture {
|
|
|
|
+ if (Std.isOfType(val, String)) {
|
|
|
|
+ var t = hxd.res.Loader.currentInstance.load(val).toTexture();
|
|
|
|
+ t.wrap = Repeat;
|
|
|
|
+ return t;
|
|
|
|
+ }
|
|
|
|
+ else if (Type.typeof(val) == TObject) {
|
|
|
|
+ var val = (val:Dynamic);
|
|
|
|
+ if (val.type != null && Std.isOfType(val.type, String)) {
|
|
|
|
+
|
|
|
|
+ switch((val.type:String):TextureType) {
|
|
|
|
+ case TextureType.gradient:
|
|
|
|
+ {
|
|
|
|
+ if (val.data.stops != null && val.data.resolution != null) {
|
|
|
|
+ var t = Gradient.textureFromData(val.data);
|
|
|
|
+ return t;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+}
|