bool WriteObjectVariable_Integer(JsonScopeObjectWriter s, object o) { var type = o.GetType(); if (type == typeof(int)) { s.WriteKeyValue("value", (int)o); } else if (type == typeof(short)) { s.WriteKeyValue("value", (short)o); } else if (type == typeof(byte)) { s.WriteKeyValue("value", (byte)o); } else if (type == typeof(long)) { s.WriteKeyValue("value", (long)o); } else { return(false); } return(true); }
public void WriteCommonObjectNode(JsonScopeObjectWriter scope, Object3DElem el) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("type", el.Type); scope.WriteKeyValue("name", el.Name); scope.WriteKeyValue("matrix", el.Matrix); scope.WriteKeyValue("visible", el.Visible); if (el.HasUserData()) { writer.WritePropertyName("userData"); WriteUserdata(el); } if (el.ChildCount > 0) { writer.WritePropertyName("children"); using (var s = new JsonScopeArrayWriter(writer)) { foreach (var child in el.Children) { child.Accept(this); } } } }
public void WriteCommonObjectNode(JsonWriter writer, JsonScopeObjectWriter scope) { scope.WriteKeyValue("uuid", Uuid); scope.WriteKeyValue("type", Type); scope.WriteKeyValue("name", Name); scope.WriteKeyValue("matrix", Matrix); scope.WriteKeyValue("visible", Visible); if ((userdata.Count + varGroupDict.Count) > 0) { writer.WritePropertyName("userdata"); WriteUserdata(writer); } if (ChildCount > 0) { writer.WritePropertyName("children"); using (var s = new JsonScopeArrayWriter(writer)) { foreach (var child in Children) { child.ExportJson(writer); } } } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("url", "./" + Name); scope.WriteKeyValue("uuid", Uuid); scope.WriteKeyValue("name", Name); } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(writer, scope); scope.WriteKeyValue("color", Color); scope.WriteKeyValue("intensity", Intensity); } }
public void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("version", Version); scope.WriteKeyValue("type", Type); scope.WriteKeyValue("generator", Generator); } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(writer, scope); scope.WriteKeyValue("geometry", Geometry.Uuid); scope.WriteKeyValue("material", Material.Uuid); } }
public void Visit(ImageElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("url", el.URL); scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("name", el.Name); } }
public void Visit(MetadataElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("version", el.Version); scope.WriteKeyValue("type", el.Type); scope.WriteKeyValue("generator", el.Generator); } }
void WriterScriptNodeVariable(JsonWriter writer, ScriptVariable val) { using (var s1 = new JsonScopeObjectWriter(writer)) { s1.WriteKeyValue("key", val.key); s1.WriteKeyValue("type", val.ShortFieldType); WriteObjectVariable(s1, val.value); } }
public void Visit(MeshElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(scope, el); scope.WriteKeyValue("geometry", el.Geometry.Uuid); scope.WriteKeyValue("material", el.Material.Uuid); } }
public void Visit(AmbientLightElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(scope, el); var helper = new LightHelper(scope, el); helper.WriteColor(); } }
void WriteUserdata(JsonWriter writer) { using (var s1 = new JsonScopeObjectWriter(writer)) { foreach (var kv in varGroupDict) { writer.WritePropertyName(kv.Key); WriteScriptVariableGroup(writer, kv.Value); } } }
void WriteScriptVariableGroup(JsonWriter writer, List <ScriptVariable> vars) { using (var s2 = new JsonScopeObjectWriter(writer)) { foreach (var val in vars) { writer.WritePropertyName(val.key); WriterScriptNodeVariable(writer, val); } } }
public void Visit(QuadBufferGeometry el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("type", el.Type); scope.WriteKeyValue("width", el.Width); scope.WriteKeyValue("height", el.Height); } }
public void Visit(SphereBufferGeometryElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("type", el.Type); scope.WriteKeyValue("radius", el.Radius.ToString()); scope.WriteKeyValue("widthSegments", 16); scope.WriteKeyValue("heightSegments", 16); } }
public void Visit(MaterialElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("name", el.Name); scope.WriteKeyValue("type", el.Type); var w = FindThreeJSWriter(el.Type); w.Write(el, scope); } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", Uuid); scope.WriteKeyValue("name", Name); scope.WriteKeyValue("type", Type); var w = FindWriter(type); w.Write(this, scope); } }
void WriteScriptVariableGroup(List <ScriptVariable> vars) { var helper = new ScriptVariableHelper(writer); using (var s2 = new JsonScopeObjectWriter(writer)) { foreach (var val in vars) { writer.WritePropertyName(val.key); helper.WriterScriptNodeVariable(val); } } }
public void Visit(CylinderBufferGeometryElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("type", el.Type); scope.WriteKeyValue("radiusTop", el.Radius); scope.WriteKeyValue("radiusBottom", el.Radius); scope.WriteKeyValue("height", el.Height); scope.WriteKeyValue("radiusSegments", 16); } }
public void Visit(PointLightElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(scope, el); var helper = new LightHelper(scope, el); helper.WriteColor(); helper.WriteIntensity(); helper.WriteDistance(); helper.WriteDecay(); } }
public void Write(MaterialElem elem, JsonScopeObjectWriter scope) { this.elem = elem; this.scope = scope; var attrs = GetAttributes(); foreach (var attr in attrs) { WriteCommonProperty(attr); } }
public void Visit(TextureElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", el.Uuid); scope.WriteKeyValue("offset", el.Offset); scope.WriteKeyValue("repeat", el.Repeat); scope.WriteKeyValue("magFilter", el.MagFilter); scope.WriteKeyValue("minFilter", el.MinFilter); scope.WriteKeyValue("wrap", el.Wrap); scope.WriteKeyValue("image", el.ImageUuid); scope.WriteKeyValue("name", el.ImagePath); scope.WriteKeyValue("anisotropy", el.Anisotropy); } }
public void Write(MaterialElem elem, JsonScopeObjectWriter scope) { this.elem = elem; this.scope = scope; var attrs = GetAttributes(); foreach (var attr in attrs) { WriteCommonProperty(attr); } WriteProperty("transparent", elem.Transparent, false); }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { scope.WriteKeyValue("uuid", Uuid); scope.WriteKeyValue("offset", Offset); scope.WriteKeyValue("repeat", Repeat); scope.WriteKeyValue("magFilter", MagFilter); scope.WriteKeyValue("minFilter", MinFilter); scope.WriteKeyValue("wrap", Wrap); scope.WriteKeyValue("image", ImageUuid); scope.WriteKeyValue("name", ImageName); scope.WriteKeyValue("anisotropy", Anisotropy); } }
public void Visit(PerspectiveCameraElem el) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(scope, el); scope.WriteKeyValue("fov", el.FOV); scope.WriteKeyValue("zoom", 1); scope.WriteKeyValue("near", el.Near); scope.WriteKeyValue("far", el.Far); scope.WriteKeyValue("focus", 10); scope.WriteKeyValue("aspect", 1); scope.WriteKeyValue("filmGauge", 35); scope.WriteKeyValue("filmOffset", 0); } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(writer, scope); scope.WriteKeyValue("fov", FOV); scope.WriteKeyValue("zoom", 1); scope.WriteKeyValue("near", Near); scope.WriteKeyValue("far", Far); scope.WriteKeyValue("focus", 10); scope.WriteKeyValue("aspect", 1); scope.WriteKeyValue("filmGauge", 35); scope.WriteKeyValue("filmOffset", 0); } }
public override void ExportJson(JsonWriter writer) { // matrix 조작 // 유니티에서는 회전된 방향으로 빛을 쏘지만 three.js에서는 카메라의 위치에서 빚을 쏜다 var forward = Vector3.forward; var direction = UnityMatrix.MultiplyVector(forward); var mat = Matrix4x4.TRS(-direction, Quaternion.identity, Vector3.one); this.UnityMatrix = mat; using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(writer, scope); scope.WriteKeyValue("color", Color); scope.WriteKeyValue("intensity", Intensity); } }
public void ExportJson(JsonWriter writer) { var visitor = new ThreeSceneExportVisitor(writer); using (var s = new JsonScopeObjectWriter(writer)) { writer.WritePropertyName("metadata"); metadata.Accept(visitor); writer.WritePropertyName("geometries"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var geometry in SharedNodeTable.GetEnumerable <AbstractGeometryElem>()) { geometry.Accept(visitor); } } writer.WritePropertyName("materials"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var material in SharedNodeTable.GetEnumerable <MaterialElem>()) { material.Accept(visitor); } } if (root != null) { writer.WritePropertyName("object"); root.Accept(visitor); } writer.WritePropertyName("images"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var image in SharedNodeTable.GetEnumerable <ImageElem>()) { image.Accept(visitor); } } writer.WritePropertyName("textures"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var tex in SharedNodeTable.GetEnumerable <TextureElem>()) { tex.Accept(visitor); } } } }
public void ExportJson(JsonWriter writer) { using (var s = new JsonScopeObjectWriter(writer)) { writer.WritePropertyName("metadata"); metadata.ExportJson(writer); writer.WritePropertyName("geometries"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var geometry in SharedNodeTable.GetEnumerable <BufferGeometryElem>()) { geometry.ExportJson(writer); } } writer.WritePropertyName("materials"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var material in SharedNodeTable.GetEnumerable <MaterialElem>()) { material.ExportJson(writer); } } if (root != null) { writer.WritePropertyName("object"); root.ExportJson(writer); } writer.WritePropertyName("images"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var image in SharedNodeTable.GetEnumerable <ImageElem>()) { image.ExportJson(writer); } } writer.WritePropertyName("textures"); using (var s1 = new JsonScopeArrayWriter(writer)) { foreach (var tex in SharedNodeTable.GetEnumerable <TextureElem>()) { tex.ExportJson(writer); } } } }
public override void ExportJson(JsonWriter writer) { using (var scope = new JsonScopeObjectWriter(writer)) { WriteCommonObjectNode(writer, scope); } }
void WriteScriptVariableGroup(JsonWriter writer, List<ScriptVariable> vars) { using (var s2 = new JsonScopeObjectWriter(writer)) { foreach (var val in vars) { writer.WritePropertyName(val.key); WriterScriptNodeVariable(writer, val); } } }
bool WriteObjectVariable_String(JsonScopeObjectWriter s, object o) { var type = o.GetType(); if (type == typeof(char)) { s.WriteKeyValue("value", (char)o); } else if (type == typeof(string)) { s.WriteKeyValue("value", (string)o); } else { return false; } return true; }
bool WriteObjectVariable_Integer(JsonScopeObjectWriter s, object o) { var type = o.GetType(); if (type == typeof(int)) { s.WriteKeyValue("value", (int)o); } else if (type == typeof(short)) { s.WriteKeyValue("value", (short)o); } else if (type == typeof(byte)) { s.WriteKeyValue("value", (byte)o); } else if (type == typeof(long)) { s.WriteKeyValue("value", (long)o); } else { return false; } return true; }
bool WriteObjectVariable_Decimal(JsonScopeObjectWriter s, object o) { var type = o.GetType(); if (type == typeof(float)) { s.WriteKeyValue("value", (float)o); } else if (type == typeof(double)) { s.WriteKeyValue("value", (double)o); } else { return false; } return true; }
void WriteObjectVariable(JsonScopeObjectWriter s, object o) { var type = o.GetType(); // primitive types if (WriteObjectVariable_Decimal(s, o)) { return; } if (WriteObjectVariable_Integer(s, o)) { return; } if (WriteObjectVariable_String(s, o)) { return; } if (type == typeof(bool)) { s.WriteKeyValue("value", (bool)o); } s.WriteKeyValue("value", o.ToString()); }
public void WriteCommonObjectNode(JsonWriter writer, JsonScopeObjectWriter scope) { scope.WriteKeyValue("uuid", Uuid); scope.WriteKeyValue("type", Type); scope.WriteKeyValue("name", Name); scope.WriteKeyValue("matrix", Matrix); scope.WriteKeyValue("visible", Visible); if((userdata.Count + varGroupDict.Count) > 0) { writer.WritePropertyName("userdata"); WriteUserdata(writer); } if (ChildCount > 0) { writer.WritePropertyName("children"); using (var s = new JsonScopeArrayWriter(writer)) { foreach (var child in Children) { child.ExportJson(writer); } } } }