{"id":2057,"date":"2023-12-23T02:52:42","date_gmt":"2023-12-22T18:52:42","guid":{"rendered":"https:\/\/usei.cn\/?p=2057"},"modified":"2023-12-23T03:01:58","modified_gmt":"2023-12-22T19:01:58","slug":"cesium-%e6%9d%90%e8%b4%a8-material","status":"publish","type":"post","link":"https:\/\/usei.cn\/index.php\/2023\/12\/23\/cesium-%e6%9d%90%e8%b4%a8-material\/","title":{"rendered":"Cesium \u6750\u8d28 Material"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u7eaf\u8272\u6750\u8d28<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>material: Cesium.Color.fromCssColorString('#20b6ff').withAlpha(0.5), \/\/ \u5899\u4f53\u989c\u8272<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"> \u56fe\u7247\u6750\u8d28<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>material: new Cesium.ImageMaterialProperty({\n    color: new Cesium.Color.fromCssColorString('rgba(255,255,255,0.9)'),\n    image: '\/cesium\/wl.png',\n}),<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u81ea\u5b9a\u4e49\u4f5c\u8272\u5668<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import * as Cesium from 'cesium'\n\/*\n * @Description: \u52a8\u6001\u6269\u6563\u5899\u7684\u5899\u4f53\u6548\u679c\uff08\u53c2\u8003\u5f00\u6e90\u4ee3\u7801\uff09\uff08\u4e0d\u540c\u9ad8\u5ea6\u900f\u660e\u5ea6\u4e0d\u540c\uff09\n * @Version: 1.0\n * @Author: Julian\n * @Date: 2022-03-07 19:50:46\n * @LastEditors: Julian\n * @LastEditTime: 2022-03-08 13:34:04\n *\/ \nexport default class WallDiffuseMaterialProperty {\n  constructor(options) {\n      this._definitionChanged = new Cesium.Event();\n      this._color = undefined;\n      this.color = options.color;\n  };\n\n  get isConstant() {\n      return false;\n  }\n\n  get definitionChanged() {\n      return this._definitionChanged;\n  }\n\n  getType(time) {\n      return Cesium.Material.WallDiffuseMaterialType;\n  }\n\n  getValue(time, result) {\n      if (!Cesium.defined(result)) {\n          result = {};\n      }\n\n      result.color = Cesium.Property.getValueOrDefault(this._color, time, Cesium.Color.RED, result.color);\n      return result\n  }\n\n  equals(other) {\n      return (this === other ||\n          (other instanceof WallDiffuseMaterialProperty &amp;&amp;\n              Cesium.Property.equals(this._color, other._color))\n      )\n  }\n}\n\nObject.defineProperties(WallDiffuseMaterialProperty.prototype, {\n  color: Cesium.createPropertyDescriptor('color'),\n})\n\n\/\/ Cesium.WallDiffuseMaterialProperty = WallDiffuseMaterialProperty;\nCesium.Material.WallDiffuseMaterialProperty = 'WallDiffuseMaterialProperty';\nCesium.Material.WallDiffuseMaterialType = 'WallDiffuseMaterialType';\nCesium.Material.WallDiffuseMaterialSource =\n  `\n  uniform vec4 color;\n  czm_material czm_getMaterial(czm_materialInput materialInput){\n  czm_material material = czm_getDefaultMaterial(materialInput);\n  vec2 st = materialInput.st;\n  material.diffuse = color.rgb * 2.0;\n  material.alpha = color.a * (1.0 - fract(st.t)) * 0.8;\n  return material;\n  }\n                                          \n  `\n\nCesium.Material._materialCache.addMaterial(Cesium.Material.WallDiffuseMaterialType, {\n  fabric: {\n      type: Cesium.Material.WallDiffuseMaterialType,\n      uniforms: {\n          color: new Cesium.Color(1.0, 0.0, 0.0, 1.0),\n      },\n      source: Cesium.Material.WallDiffuseMaterialSource\n  },\n  translucent: function(material) {\n      return true;\n  }\n})\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u6269\u6563\u5899\u6750\u8d28\r\nmaterial: new WallDiffuseMaterialProperty({\r\n    color: new Cesium.Color(1.0, 1.0, 0.0, 1.0)\r\n}),<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7eaf\u8272\u6750\u8d28 \u56fe\u7247\u6750\u8d28 \u81ea\u5b9a\u4e49\u4f5c\u8272\u5668<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-2057","post","type-post","status-publish","format-standard","hentry","category-cesium"],"_links":{"self":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/2057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2057"}],"version-history":[{"count":5,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/2057\/revisions"}],"predecessor-version":[{"id":2062,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/2057\/revisions\/2062"}],"wp:attachment":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}