読者です 読者をやめる 読者になる 読者になる

JSONとXML

ColladaView

ColladaViewに使うという前提でいろいろ。

まず基本となるFlashvars

var flashvars = {
				filename:'ineine/inekun.dae,ineine/inechan.dae',
				position:'100:0:0,-100:0:0,0:0:0', 
				rotation:'0:180:0,0:0:0,0:0:0',
				scale:'0.5,0.5,0.5',
				extexload:',,',
				animation:'yes,yes',
				cameradistance:'5000',
				bgimage:'',
				bgtiling:'no'
};

JSONにしてみる

{
	"background": {
		"src": "1225465206506.png",
		"tiling": false
	},
	"camera": {
		"distance": 5000,
		"center": [0, 0, 0]
	},
	"model": [
		{
			"id": "inekun",
			"src": "ineine/inekun",
			"scale": 0.5,
			"position": [100, 0, 0],
			"rotation": [0, 180, 0],
			"extended": null,
			"animation": true
		},
		{
			"id": "inechan",
			"src": "ineine/inechan.dae",
			"scale": 0.5,
			"position": [-100, 0, 0],
			"rotation": [0, 0, 0],
			"extended": null,
			"animation": true
		}
	]
}

カンマの位置とかで躓きそうな気もする
XML-JSON相互変換ツールを使ってXMLにしてみる

<?xml version="1.0" encoding="UTF-8" ?>
<background>
  <src>1225465206506.png</src>
  <tiling>false</tiling>
</background>
<camera>
  <distance>5000</distance>
  <center>0</center>
  <center>0</center>
  <center>0</center>
</camera>
<model>
  <id>inekun</id>
  <src>ineine/inekun</src>
  <scale>0.5</scale>
  <position>100</position>
  <position>0</position>
  <position>0</position>
  <rotation>0</rotation>
  <rotation>180</rotation>
  <rotation>0</rotation>
  <extended /><animation>true</animation>
</model>
<model>
  <id>inechan</id>
  <src>ineine/inechan.dae</src>
  <scale>0.5</scale>
  <position>-100</position>
  <position>0</position>
  <position>0</position>
  <rotation>0</rotation>
  <rotation>0</rotation>
  <rotation>0</rotation>
  <extended /><animation>true</animation>
</model>

ちょっと修正してみる

<?xml version="1.0" encoding="UTF-8" ?>
<background>
  <src>1225465206506.png</src>
  <tiling>false</tiling>
</background>
<camera>
  <distance>5000</distance>
  <center x="0" y="0" z="0"></center>
</camera>
<model>
  <id>inekun</id>
  <src>ineine/inekun</src>
  <scale>0.5</scale>
  <position x="100" y="0" z="0" />
  <rotation x="100" y="180" z="0" />
  <extended />
  <animation>true</animation>
</model>
<model>
  <id>inechan</id>
  <src>ineine/inechan.dae</src>
  <scale>0.5</scale>
  <position x="-100" y="0" z="0" />
  <rotation x="0" y="0" z="0" />
  <extended />
  <animation>true</animation>
</model>

なんか冗長。

JSONでいいか。