babylon.standardMaterial.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var maxSimultaneousLights = 4;
  10. var StandardMaterial = (function (_super) {
  11. __extends(StandardMaterial, _super);
  12. function StandardMaterial(name, scene) {
  13. var _this = this;
  14. _super.call(this, name, scene);
  15. this.ambientColor = new BABYLON.Color3(0, 0, 0);
  16. this.diffuseColor = new BABYLON.Color3(1, 1, 1);
  17. this.specularColor = new BABYLON.Color3(1, 1, 1);
  18. this.specularPower = 64;
  19. this.emissiveColor = new BABYLON.Color3(0, 0, 0);
  20. this.useAlphaFromDiffuseTexture = false;
  21. this._cachedDefines = null;
  22. this._renderTargets = new BABYLON.SmartArray(16);
  23. this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
  24. this._globalAmbientColor = new BABYLON.Color3(0, 0, 0);
  25. this._baseColor = new BABYLON.Color3();
  26. this._scaledDiffuse = new BABYLON.Color3();
  27. this._scaledSpecular = new BABYLON.Color3();
  28. this.getRenderTargetTextures = function () {
  29. _this._renderTargets.reset();
  30. if (_this.reflectionTexture && _this.reflectionTexture.isRenderTarget) {
  31. _this._renderTargets.push(_this.reflectionTexture);
  32. }
  33. return _this._renderTargets;
  34. };
  35. }
  36. StandardMaterial.prototype.needAlphaBlending = function () {
  37. return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture();
  38. };
  39. StandardMaterial.prototype.needAlphaTesting = function () {
  40. return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && !this.diffuseTexture.getAlphaFromRGB;
  41. };
  42. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  43. return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && this.useAlphaFromDiffuseTexture;
  44. };
  45. StandardMaterial.prototype.getAlphaTestTexture = function () {
  46. return this.diffuseTexture;
  47. };
  48. // Methods
  49. StandardMaterial.prototype.isReady = function (mesh, useInstances) {
  50. if (this.checkReadyOnlyOnce) {
  51. if (this._wasPreviouslyReady) {
  52. return true;
  53. }
  54. }
  55. var scene = this.getScene();
  56. if (!this.checkReadyOnEveryCall) {
  57. if (this._renderId === scene.getRenderId()) {
  58. return true;
  59. }
  60. }
  61. var engine = scene.getEngine();
  62. var defines = [];
  63. var optionalDefines = new Array();
  64. // Textures
  65. if (scene.texturesEnabled) {
  66. if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  67. if (!this.diffuseTexture.isReady()) {
  68. return false;
  69. } else {
  70. defines.push("#define DIFFUSE");
  71. }
  72. }
  73. if (this.ambientTexture && BABYLON.StandardMaterial.AmbientTextureEnabled) {
  74. if (!this.ambientTexture.isReady()) {
  75. return false;
  76. } else {
  77. defines.push("#define AMBIENT");
  78. }
  79. }
  80. if (this.opacityTexture && BABYLON.StandardMaterial.OpacityTextureEnabled) {
  81. if (!this.opacityTexture.isReady()) {
  82. return false;
  83. } else {
  84. defines.push("#define OPACITY");
  85. if (this.opacityTexture.getAlphaFromRGB) {
  86. defines.push("#define OPACITYRGB");
  87. }
  88. }
  89. }
  90. if (this.reflectionTexture && BABYLON.StandardMaterial.ReflectionTextureEnabled) {
  91. if (!this.reflectionTexture.isReady()) {
  92. return false;
  93. } else {
  94. defines.push("#define REFLECTION");
  95. }
  96. }
  97. if (this.emissiveTexture && BABYLON.StandardMaterial.EmissiveTextureEnabled) {
  98. if (!this.emissiveTexture.isReady()) {
  99. return false;
  100. } else {
  101. defines.push("#define EMISSIVE");
  102. }
  103. }
  104. if (this.specularTexture && BABYLON.StandardMaterial.SpecularTextureEnabled) {
  105. if (!this.specularTexture.isReady()) {
  106. return false;
  107. } else {
  108. defines.push("#define SPECULAR");
  109. optionalDefines.push(defines[defines.length - 1]);
  110. }
  111. }
  112. }
  113. if (scene.getEngine().getCaps().standardDerivatives && this.bumpTexture && BABYLON.StandardMaterial.BumpTextureEnabled) {
  114. if (!this.bumpTexture.isReady()) {
  115. return false;
  116. } else {
  117. defines.push("#define BUMP");
  118. optionalDefines.push(defines[defines.length - 1]);
  119. }
  120. }
  121. // Effect
  122. if (scene.clipPlane) {
  123. defines.push("#define CLIPPLANE");
  124. }
  125. if (engine.getAlphaTesting()) {
  126. defines.push("#define ALPHATEST");
  127. }
  128. if (this._shouldUseAlphaFromDiffuseTexture()) {
  129. defines.push("#define ALPHAFROMDIFFUSE");
  130. }
  131. // Fog
  132. if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  133. defines.push("#define FOG");
  134. optionalDefines.push(defines[defines.length - 1]);
  135. }
  136. var shadowsActivated = false;
  137. var lightIndex = 0;
  138. if (scene.lightsEnabled) {
  139. for (var index = 0; index < scene.lights.length; index++) {
  140. var light = scene.lights[index];
  141. if (!light.isEnabled()) {
  142. continue;
  143. }
  144. // Excluded check
  145. if (light._excludedMeshesIds.length > 0) {
  146. for (var excludedIndex = 0; excludedIndex < light._excludedMeshesIds.length; excludedIndex++) {
  147. var excludedMesh = scene.getMeshByID(light._excludedMeshesIds[excludedIndex]);
  148. if (excludedMesh) {
  149. light.excludedMeshes.push(excludedMesh);
  150. }
  151. }
  152. light._excludedMeshesIds = [];
  153. }
  154. // Included check
  155. if (light._includedOnlyMeshesIds.length > 0) {
  156. for (var includedOnlyIndex = 0; includedOnlyIndex < light._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  157. var includedOnlyMesh = scene.getMeshByID(light._includedOnlyMeshesIds[includedOnlyIndex]);
  158. if (includedOnlyMesh) {
  159. light.includedOnlyMeshes.push(includedOnlyMesh);
  160. }
  161. }
  162. light._includedOnlyMeshesIds = [];
  163. }
  164. if (!light.canAffectMesh(mesh)) {
  165. continue;
  166. }
  167. defines.push("#define LIGHT" + lightIndex);
  168. if (lightIndex > 0) {
  169. optionalDefines.push(defines[defines.length - 1]);
  170. }
  171. var type;
  172. if (light instanceof BABYLON.SpotLight) {
  173. type = "#define SPOTLIGHT" + lightIndex;
  174. } else if (light instanceof BABYLON.HemisphericLight) {
  175. type = "#define HEMILIGHT" + lightIndex;
  176. } else {
  177. type = "#define POINTDIRLIGHT" + lightIndex;
  178. }
  179. defines.push(type);
  180. if (lightIndex > 0) {
  181. optionalDefines.push(defines[defines.length - 1]);
  182. }
  183. // Shadows
  184. var shadowGenerator = light.getShadowGenerator();
  185. if (mesh && mesh.receiveShadows && shadowGenerator) {
  186. defines.push("#define SHADOW" + lightIndex);
  187. if (lightIndex > 0) {
  188. optionalDefines.push(defines[defines.length - 1]);
  189. }
  190. if (!shadowsActivated) {
  191. defines.push("#define SHADOWS");
  192. shadowsActivated = true;
  193. }
  194. if (shadowGenerator.useVarianceShadowMap) {
  195. defines.push("#define SHADOWVSM" + lightIndex);
  196. if (lightIndex > 0) {
  197. optionalDefines.push(defines[defines.length - 1]);
  198. }
  199. }
  200. if (shadowGenerator.usePoissonSampling) {
  201. defines.push("#define SHADOWPCF" + lightIndex);
  202. if (lightIndex > 0) {
  203. optionalDefines.push(defines[defines.length - 1]);
  204. }
  205. }
  206. }
  207. lightIndex++;
  208. if (lightIndex == maxSimultaneousLights)
  209. break;
  210. }
  211. }
  212. var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
  213. if (mesh) {
  214. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
  215. attribs.push(BABYLON.VertexBuffer.UVKind);
  216. defines.push("#define UV1");
  217. }
  218. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
  219. attribs.push(BABYLON.VertexBuffer.UV2Kind);
  220. defines.push("#define UV2");
  221. }
  222. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
  223. attribs.push(BABYLON.VertexBuffer.ColorKind);
  224. defines.push("#define VERTEXCOLOR");
  225. }
  226. if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
  227. attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
  228. attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
  229. defines.push("#define BONES");
  230. defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
  231. defines.push("#define BONES4");
  232. optionalDefines.push(defines[defines.length - 1]);
  233. }
  234. // Instances
  235. if (useInstances) {
  236. defines.push("#define INSTANCES");
  237. attribs.push("world0");
  238. attribs.push("world1");
  239. attribs.push("world2");
  240. attribs.push("world3");
  241. }
  242. }
  243. // Get correct effect
  244. var join = defines.join("\n");
  245. if (this._cachedDefines != join) {
  246. this._cachedDefines = join;
  247. // Legacy browser patch
  248. var shaderName = "default";
  249. if (!scene.getEngine().getCaps().standardDerivatives) {
  250. shaderName = "legacydefault";
  251. }
  252. this._effect = scene.getEngine().createEffect(shaderName, attribs, [
  253. "world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  254. "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0", "lightMatrix0",
  255. "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1",
  256. "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
  257. "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3",
  258. "vFogInfos", "vFogColor",
  259. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
  260. "mBones",
  261. "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix",
  262. "darkness0", "darkness1", "darkness2", "darkness3"], [
  263. "diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
  264. "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
  265. ], join, optionalDefines, this.onCompiled, this.onError);
  266. }
  267. if (!this._effect.isReady()) {
  268. return false;
  269. }
  270. this._renderId = scene.getRenderId();
  271. this._wasPreviouslyReady = true;
  272. return true;
  273. };
  274. StandardMaterial.prototype.unbind = function () {
  275. if (this.reflectionTexture && this.reflectionTexture.isRenderTarget) {
  276. this._effect.setTexture("reflection2DSampler", null);
  277. }
  278. };
  279. StandardMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  280. this._effect.setMatrix("world", world);
  281. };
  282. StandardMaterial.prototype.bind = function (world, mesh) {
  283. var scene = this.getScene();
  284. this._baseColor.copyFrom(this.diffuseColor);
  285. // Matrices
  286. this.bindOnlyWorldMatrix(world);
  287. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  288. // Bones
  289. if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
  290. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
  291. }
  292. // Textures
  293. if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  294. this._effect.setTexture("diffuseSampler", this.diffuseTexture);
  295. this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
  296. this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
  297. this._baseColor.copyFromFloats(1, 1, 1);
  298. }
  299. if (this.ambientTexture && BABYLON.StandardMaterial.AmbientTextureEnabled) {
  300. this._effect.setTexture("ambientSampler", this.ambientTexture);
  301. this._effect.setFloat2("vAmbientInfos", this.ambientTexture.coordinatesIndex, this.ambientTexture.level);
  302. this._effect.setMatrix("ambientMatrix", this.ambientTexture.getTextureMatrix());
  303. }
  304. if (this.opacityTexture && BABYLON.StandardMaterial.OpacityTextureEnabled) {
  305. this._effect.setTexture("opacitySampler", this.opacityTexture);
  306. this._effect.setFloat2("vOpacityInfos", this.opacityTexture.coordinatesIndex, this.opacityTexture.level);
  307. this._effect.setMatrix("opacityMatrix", this.opacityTexture.getTextureMatrix());
  308. }
  309. if (this.reflectionTexture && BABYLON.StandardMaterial.ReflectionTextureEnabled) {
  310. if (this.reflectionTexture.isCube) {
  311. this._effect.setTexture("reflectionCubeSampler", this.reflectionTexture);
  312. } else {
  313. this._effect.setTexture("reflection2DSampler", this.reflectionTexture);
  314. }
  315. this._effect.setMatrix("reflectionMatrix", this.reflectionTexture.getReflectionTextureMatrix());
  316. this._effect.setFloat3("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level, this.reflectionTexture.isCube ? 1 : 0);
  317. }
  318. if (this.emissiveTexture && BABYLON.StandardMaterial.EmissiveTextureEnabled) {
  319. this._effect.setTexture("emissiveSampler", this.emissiveTexture);
  320. this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level);
  321. this._effect.setMatrix("emissiveMatrix", this.emissiveTexture.getTextureMatrix());
  322. }
  323. if (this.specularTexture && BABYLON.StandardMaterial.SpecularTextureEnabled) {
  324. this._effect.setTexture("specularSampler", this.specularTexture);
  325. this._effect.setFloat2("vSpecularInfos", this.specularTexture.coordinatesIndex, this.specularTexture.level);
  326. this._effect.setMatrix("specularMatrix", this.specularTexture.getTextureMatrix());
  327. }
  328. if (this.bumpTexture && scene.getEngine().getCaps().standardDerivatives && BABYLON.StandardMaterial.BumpTextureEnabled) {
  329. this._effect.setTexture("bumpSampler", this.bumpTexture);
  330. this._effect.setFloat2("vBumpInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
  331. this._effect.setMatrix("bumpMatrix", this.bumpTexture.getTextureMatrix());
  332. }
  333. // Colors
  334. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  335. this._effect.setVector3("vEyePosition", scene.activeCamera.position);
  336. this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
  337. this._effect.setColor4("vDiffuseColor", this._baseColor, this.alpha * mesh.visibility);
  338. this._effect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  339. this._effect.setColor3("vEmissiveColor", this.emissiveColor);
  340. if (scene.lightsEnabled) {
  341. var lightIndex = 0;
  342. for (var index = 0; index < scene.lights.length; index++) {
  343. var light = scene.lights[index];
  344. if (!light.isEnabled()) {
  345. continue;
  346. }
  347. if (!light.canAffectMesh(mesh)) {
  348. continue;
  349. }
  350. if (light instanceof BABYLON.PointLight) {
  351. // Point Light
  352. light.transferToEffect(this._effect, "vLightData" + lightIndex);
  353. } else if (light instanceof BABYLON.DirectionalLight) {
  354. // Directional Light
  355. light.transferToEffect(this._effect, "vLightData" + lightIndex);
  356. } else if (light instanceof BABYLON.SpotLight) {
  357. // Spot Light
  358. light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
  359. } else if (light instanceof BABYLON.HemisphericLight) {
  360. // Hemispheric Light
  361. light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
  362. }
  363. light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
  364. light.specular.scaleToRef(light.intensity, this._scaledSpecular);
  365. this._effect.setColor4("vLightDiffuse" + lightIndex, this._scaledDiffuse, light.range);
  366. this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
  367. // Shadows
  368. var shadowGenerator = light.getShadowGenerator();
  369. if (mesh.receiveShadows && shadowGenerator) {
  370. this._effect.setMatrix("lightMatrix" + lightIndex, shadowGenerator.getTransformMatrix());
  371. this._effect.setTexture("shadowSampler" + lightIndex, shadowGenerator.getShadowMap());
  372. this._effect.setFloat("darkness" + lightIndex, shadowGenerator.getDarkness());
  373. }
  374. lightIndex++;
  375. if (lightIndex == maxSimultaneousLights)
  376. break;
  377. }
  378. }
  379. if (scene.clipPlane) {
  380. var clipPlane = scene.clipPlane;
  381. this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  382. }
  383. // View
  384. if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE || this.reflectionTexture) {
  385. this._effect.setMatrix("view", scene.getViewMatrix());
  386. }
  387. // Fog
  388. if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  389. this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  390. this._effect.setColor3("vFogColor", scene.fogColor);
  391. }
  392. };
  393. StandardMaterial.prototype.getAnimatables = function () {
  394. var results = [];
  395. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  396. results.push(this.diffuseTexture);
  397. }
  398. if (this.ambientTexture && this.ambientTexture.animations && this.ambientTexture.animations.length > 0) {
  399. results.push(this.ambientTexture);
  400. }
  401. if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) {
  402. results.push(this.opacityTexture);
  403. }
  404. if (this.reflectionTexture && this.reflectionTexture.animations && this.reflectionTexture.animations.length > 0) {
  405. results.push(this.reflectionTexture);
  406. }
  407. if (this.emissiveTexture && this.emissiveTexture.animations && this.emissiveTexture.animations.length > 0) {
  408. results.push(this.emissiveTexture);
  409. }
  410. if (this.specularTexture && this.specularTexture.animations && this.specularTexture.animations.length > 0) {
  411. results.push(this.specularTexture);
  412. }
  413. if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
  414. results.push(this.bumpTexture);
  415. }
  416. return results;
  417. };
  418. StandardMaterial.prototype.dispose = function (forceDisposeEffect) {
  419. if (this.diffuseTexture) {
  420. this.diffuseTexture.dispose();
  421. }
  422. if (this.ambientTexture) {
  423. this.ambientTexture.dispose();
  424. }
  425. if (this.opacityTexture) {
  426. this.opacityTexture.dispose();
  427. }
  428. if (this.reflectionTexture) {
  429. this.reflectionTexture.dispose();
  430. }
  431. if (this.emissiveTexture) {
  432. this.emissiveTexture.dispose();
  433. }
  434. if (this.specularTexture) {
  435. this.specularTexture.dispose();
  436. }
  437. if (this.bumpTexture) {
  438. this.bumpTexture.dispose();
  439. }
  440. _super.prototype.dispose.call(this, forceDisposeEffect);
  441. };
  442. StandardMaterial.prototype.clone = function (name) {
  443. var newStandardMaterial = new BABYLON.StandardMaterial(name, this.getScene());
  444. // Base material
  445. newStandardMaterial.checkReadyOnEveryCall = this.checkReadyOnEveryCall;
  446. newStandardMaterial.alpha = this.alpha;
  447. newStandardMaterial.wireframe = this.wireframe;
  448. newStandardMaterial.backFaceCulling = this.backFaceCulling;
  449. // Standard material
  450. if (this.diffuseTexture && this.diffuseTexture.clone) {
  451. newStandardMaterial.diffuseTexture = this.diffuseTexture.clone();
  452. }
  453. if (this.ambientTexture && this.ambientTexture.clone) {
  454. newStandardMaterial.ambientTexture = this.ambientTexture.clone();
  455. }
  456. if (this.opacityTexture && this.opacityTexture.clone) {
  457. newStandardMaterial.opacityTexture = this.opacityTexture.clone();
  458. }
  459. if (this.reflectionTexture && this.reflectionTexture.clone) {
  460. newStandardMaterial.reflectionTexture = this.reflectionTexture.clone();
  461. }
  462. if (this.emissiveTexture && this.emissiveTexture.clone) {
  463. newStandardMaterial.emissiveTexture = this.emissiveTexture.clone();
  464. }
  465. if (this.specularTexture && this.specularTexture.clone) {
  466. newStandardMaterial.specularTexture = this.specularTexture.clone();
  467. }
  468. if (this.bumpTexture && this.bumpTexture.clone) {
  469. newStandardMaterial.bumpTexture = this.bumpTexture.clone();
  470. }
  471. newStandardMaterial.ambientColor = this.ambientColor.clone();
  472. newStandardMaterial.diffuseColor = this.diffuseColor.clone();
  473. newStandardMaterial.specularColor = this.specularColor.clone();
  474. newStandardMaterial.specularPower = this.specularPower;
  475. newStandardMaterial.emissiveColor = this.emissiveColor.clone();
  476. return newStandardMaterial;
  477. };
  478. StandardMaterial.DiffuseTextureEnabled = true;
  479. StandardMaterial.AmbientTextureEnabled = true;
  480. StandardMaterial.OpacityTextureEnabled = true;
  481. StandardMaterial.ReflectionTextureEnabled = true;
  482. StandardMaterial.EmissiveTextureEnabled = true;
  483. StandardMaterial.SpecularTextureEnabled = true;
  484. StandardMaterial.BumpTextureEnabled = true;
  485. return StandardMaterial;
  486. })(BABYLON.Material);
  487. BABYLON.StandardMaterial = StandardMaterial;
  488. })(BABYLON || (BABYLON = {}));
  489. //# sourceMappingURL=babylon.standardMaterial.js.map