{"id":6470,"date":"2019-07-19T15:49:45","date_gmt":"2019-07-19T06:49:45","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=6470"},"modified":"2020-07-16T12:16:24","modified_gmt":"2020-07-16T03:16:24","slug":"deckgl%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%80%81d3%e3%81%a7%e8%a8%88%e7%ae%97%e3%81%97%e3%81%9f%e3%83%8d%e3%83%83%e3%83%88%e3%83%af%e3%83%bc%e3%82%af%e3%82%b0%e3%83%a9%e3%83%95%e3%82%92webgl","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3v4\/6470","title":{"rendered":"deck.gl\u3092\u4f7f\u3063\u3066\u3001D3.js\u3067\u8a08\u7b97\u3057\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3092WebGL\u3067\u63cf\u753b\u3059\u308b"},"content":{"rendered":"<h2>\u6982\u8981<\/h2>\n<p>deck.gl\u306f\u3001Uber\u793e\u304c\u5de8\u5927\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u5730\u56f3\u4e0a\u306b\u53ef\u8996\u5316\u3059\u308b\u305f\u3081\u306b\u4f5c\u3063\u305f\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u304c\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306e\u3054\u3068\u306b\u9032\u5316\u3092\u9042\u3052\u3001\u73fe\u5728\u3067\u306f\u5730\u7406\u7a7a\u9593\u30c7\u30fc\u30bf\u306b\u95a2\u308f\u3089\u305a\u3001\u69d8\u3005\u306a\u5ea7\u6a19\u7cfb\u306b\u5bfe\u5fdc\u3057\u305f\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30bc\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u3001D3\u3092\u4f7f\u3063\u3066\u8a08\u7b97\u3057\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3092Deck.gl\u3092\u7528\u3044\u3066WebGL\u306b\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3092WebGL\u3092\u4f7f\u3063\u3066\u63cf\u753b\u3059\u308b<\/h2>\n<p><a href=\"https:\/\/0q0hx.csb.app\/\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/07\/deckgl-d3-force.png\" alt=\"\" width=\"1812\" height=\"1019\" class=\"aligncenter size-full wp-image-6471 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/07\/deckgl-d3-force.png 1812w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/07\/deckgl-d3-force-267x150.png 267w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/07\/deckgl-d3-force-768x432.png 768w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2019\/07\/deckgl-d3-force-1024x576.png 1024w\" sizes=\"auto, (max-width: 1812px) 100vw, 1812px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/0q0hx.csb.app\/\">DENO<\/a><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<p><iframe\n     src=\"https:\/\/codesandbox.io\/embed\/d3-forcesumulateion-0q0hx?fontsize=14&#038;hidenavigation=1&#038;theme=dark&#038;view=split\"\n     style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\"\n     title=\"d3-forcesumulateion\"\n     allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n     sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n   ><\/iframe><\/p>\n<h3>\u89e3\u8aac<\/h3>\n<h4>deck.gl\u306e\u30d3\u30e5\u30fc\u30b7\u30b9\u30c6\u30e0<\/h4>\n<p>deck.gl\u3067\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5730\u7406\u7a7a\u9593\u30c7\u30fc\u30bf\u3092\u63cf\u753b\u3059\u308b\u305f\u3081\u306e\u30d3\u30e5\u30fc(<code>Mapview<\/code>)\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\ndeck.gl\u306b\u306f<code>Mapview<\/code>\u306e\u4ed6\u306b\u3082\u3001\u3055\u307e\u3056\u307e\u306a\u5ea7\u6a19\u30c7\u30fc\u30bf\u306b\u5bfe\u5fdc\u3057\u305fview\u304c\u7528\u610f\u3055\u308c\u304a\u308a\u3001\u958b\u767a\u8005\u304c\u5730\u7406\u7a7a\u9593\u30c7\u30fc\u30bf\u4ee5\u5916\u306e\u30c7\u30fc\u30bf\u3067\u3082webGL\u3092\u7528\u3044\u3066\u63cf\u753b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\uff08\u5404view\u306b\u306f\u3001\u30c7\u30fc\u30bf\u306e\u5ea7\u6a19\u3092\u30b9\u30af\u30ea\u30fc\u30f3\u4e0a\u306e\u5ea7\u6a19\u306b\u5909\u63db\u3059\u308b\u6295\u5f71\u6cd5\u3068\u3001\u30ab\u30e1\u30e9\u306e\u30b3\u30f3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u8a2d\u5b9a\u304c\u30ef\u30f3\u30bb\u30c3\u30c8\u3068\u306a\u3063\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3055\u308c\u3066\u3044\u307e\u3059\uff09<br \/>\n\u3053\u3053\u3067\u306f\u30013D(x,y,z)\u5ea7\u6a19\u306e\u6295\u5f71\u6cd5\u3068\u3001\u6307\u5b9a\u3057\u305f\u5ea7\u6a19\u3092\u4e2d\u5fc3\u3068\u3057\u3066\u56de\u8ee2\u3059\u308b\u30ab\u30e1\u30e9\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u5b9a\u7fa9\u3055\u308c\u305f\uff08<code>OrbitView<\/code>\uff09\u3092\u4f7f\u3063\u3066\u3001D3\u3067\u751f\u6210\u3057\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3092webGL\u4e0a\u306b\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n<h4>d3.forceSimulation\u306e\u8a08\u7b97\u7d50\u679c\u3092deck.gl\u306b\u53cd\u6620\u3055\u305b\u308b<\/h4>\n<p>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u306e\u5ea7\u6a19\u8a08\u7b97\u306b\u3064\u3044\u3066\u8a73\u3057\u3044\u4ed5\u7d44\u307f\u306f <a href=\"https:\/\/github.com\/d3\/d3-force\">d3-force<\/a> \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u3053\u3053\u3067\u306e\u30dd\u30a4\u30f3\u30c8\u306f\u3001<code>forceSimulation<\/code>\u306e\u5185\u90e8\u30bf\u30a4\u30de\u30fc\u306b\u3088\u3063\u3066\u9001\u51fa\u3055\u308c\u308b<code>tick<\/code>\u30a4\u30d9\u30f3\u30c8\u3092\u6355\u307e\u3048\u3066\u3001\u30b7\u30e5\u30df\u30ec\u30fc\u30bf\u30fc\u306b\u3088\u3063\u3066\u8a08\u7b97\u3055\u308c\u305f\u30ce\u30fc\u30c9\u3068\u30ea\u30f3\u30af\u306e\u5ea7\u6a19\u3092deck.gl\u306e<code>ScatterplotLayer<\/code>\u3068<code>LineLayer<\/code>\u306b\u53cd\u6620\u3057\u3066\u3044\u308b\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u57fa\u672c\u7684\u306b\u306f\u3001\u30ce\u30fc\u30c9\u3068\u30ea\u30f3\u30af\u7528\u306e\u30b9\u30c6\u30fc\u30c8\u3092\u751f\u6210\u3057\u3001<code>tick<\/code>\u30a4\u30d9\u30f3\u30c8\u5185\u3067\u3001\u8a08\u7b97\u3055\u308c\u305f\u5ea7\u6a19\u3092\u30ec\u30a4\u30e4\u30fc\u306b\u53cd\u6620\u3059\u308b\u308f\u3051\u3067\u3059\u304c\u3001\u3053\u306e\u6642\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3068\u3057\u3066\u8a08\u7b97\u7d50\u679c\u304c\u53ce\u3081\u3089\u308c\u305f\u30c7\u30fc\u30bf\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5225\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8907\u88fd\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nD3.js\u306f\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u306b\u6e21\u3055\u308c\u305f\u30c7\u30fc\u30bf\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u7834\u58ca\u7684\u306b\u66f4\u65b0\u3057\u307e\u3059\u304c\u3001\u3053\u308c\u3092\u305d\u306e\u307e\u307e\u30b9\u30c6\u30fc\u30c8\u306b\u6e21\u3057\u3066\u3082\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u304c\u691c\u77e5\u3055\u308c\u305a\u30ec\u30f3\u30c0\u30fc\u304c\u8d70\u3089\u306a\u3044\u305f\u3081\u3067\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001<code>JSON.stringify<\/code>\u3068<code>JSON.parse<\/code>\u3092\u4f7f\u3063\u305f\u3042\u307e\u308a\u30b9\u30de\u30fc\u30c8\u3067\u306a\u3044\u30c7\u30a3\u30fc\u30d7\u30b3\u30d4\u30fc\u3092\u884c\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u3082\u3046\u3061\u3087\u3063\u3068\u6539\u5584\u306e\u4f59\u5730\u304c\u3042\u308b\u304b\u3082\u3002<\/p>\n<pre class=\"lang:js decode:true \" >\n\/\/\u30ce\u30fc\u30c9\u3068\u30ea\u30f3\u30af\u7528\u306estate\u3092\u8a2d\u5b9a\nconst [nodes, setNodes] = useState(data.nodes);\nconst [links, setLinks] = useState(data.links);\n\n\n\/\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u306e\u5ea7\u6a19\u8a08\u7b97\u3092\u884c\u3046\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u3092\u751f\u6210\nconst simulation = forceSimulation()\n    .force(\n        \"link\",\n        forceLink().id(function (d) {\n            return d.id;\n        })\n    )\n    .force(\"charge\", forceManyBody())\n    .force(\"center\", forceCenter(0, 0));\n\n\/\/\u30ce\u30fc\u30c9\u3068\u30ea\u30f3\u30af\u306e\u30c7\u30fc\u30bf\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u306b\u675f\u7e1b\nsimulation.nodes(data.nodes);\nsimulation.force(\"link\").links(data.links);\n\n\/\/\u30eb\u30fc\u30d7\u30a4\u30d9\u30f3\u30c8\u6642\u306b\u547c\u3070\u308c\u308b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u8a2d\u5b9a\nconst ticked = () =&gt; {\n    \/\/render\u3092\u8d70\u3089\u305b\u308b\u70ba\u306b\u5ea7\u6a19\u8a08\u7b97\u6e08\u307f\u306e\u30c7\u30fc\u30bf\u3092\u5225\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8907\u88fd\n    const newData = JSON.parse(JSON.stringify(data));\n    \/\/react state\u3092\u66f4\u65b0\n    setNodes(newData.nodes);\n    setLinks(newData.links);\n};\n\n\n\/\/\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u306e\u30eb\u30fc\u30d7\u30a4\u30d9\u30f3\u30c8\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u675f\u7e1b\nsimulation.on(\"tick\", ticked);<\/pre>\n<h2>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u81ea\u4f53\u30823D\u306b\u3059\u308b<\/h2>\n<p>\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001z\u8ef8\u3082\u542b\u3081\u3066\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u306e\u5ea7\u6a19\u8a08\u7b97\u3092\u884c\u3046d3-force-3d\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u3063\u30663D\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3082\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u57fa\u672c\u7684\u306a\u5185\u5bb9\u306f\u5909\u308f\u3063\u3066\u3044\u307e\u305b\u3093\u3001d3-force\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3063\u3066\u3044\u305f\u3068\u3053\u308d\u3092\u3001d3-force-3d\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u5909\u3048\u3001\u30ce\u30fc\u30c9\u3092\u63cf\u753b\u3059\u308b\u306e\u306b<code>ScatterplotLayer<\/code>\u3067\u306f\u306a\u304f<code>PointCloudLayer<\/code>\u3092\u4f7f\u3046\u3088\u3046\u306b\u5909\u66f4\u3057\u305f\u3060\u3051\u3067\u3059\u3002\uff08<code>ScatterplotLaye<\/code>\u306b\u306fz\u8ef8\u3092\u63cf\u753b\u3059\u308b\u6a5f\u80fd\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001<code>PointCloudLayer<\/code>\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\uff09<\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<p><iframe\n     src=\"https:\/\/codesandbox.io\/embed\/d3-force-3d-tocpm?fontsize=14&#038;hidenavigation=1&#038;theme=dark&#038;view=split\"\n     style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\"\n     title=\"d3-force-3d\"\n     allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n     sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n   ><\/iframe><\/p>\n<p>deck.gl\u306b\u306f\u3001\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u30c6\u30af\u30b9\u30c1\u30e3\u30fc\u3092\u8cbc\u3063\u305f\u308a\u30de\u30c6\u30ea\u30a2\u30eb\u3092\u7d30\u304b\u304f\u8a2d\u5b9a\u3059\u308b\u6a5f\u80fd\u5099\u308f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3088\u308a\u7d30\u304b\u304f\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 deck.gl\u306f\u3001Uber\u793e\u304c\u5de8\u5927\u306a\u30c7\u30fc\u30bf\u30bb&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6471,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,73],"tags":[],"class_list":["post-6470","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3v4","category-deck-gl","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=6470"}],"version-history":[{"count":1,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6470\/revisions"}],"predecessor-version":[{"id":6894,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6470\/revisions\/6894"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/6471"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=6470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=6470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=6470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}