|
@@ -1,192 +1,392 @@
|
|
|
-/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
|
-var __extends = (this && this.__extends) || (function () {
|
|
|
- var extendStatics = function (d, b) {
|
|
|
- extendStatics = Object.setPrototypeOf ||
|
|
|
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
- return extendStatics(d, b);
|
|
|
- }
|
|
|
- return function (d, b) {
|
|
|
- extendStatics(d, b);
|
|
|
- function __() { this.constructor = d; }
|
|
|
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
- };
|
|
|
+(function webpackUniversalModuleDefinition(root, factory) {
|
|
|
+ if(typeof exports === 'object' && typeof module === 'object')
|
|
|
+ module.exports = factory(require("babylonjs"));
|
|
|
+ else if(typeof define === 'function' && define.amd)
|
|
|
+ define("babylonjs-materials", ["babylonjs"], factory);
|
|
|
+ else if(typeof exports === 'object')
|
|
|
+ exports["babylonjs-materials"] = factory(require("babylonjs"));
|
|
|
+ else
|
|
|
+ root["MATLIB"] = factory(root["BABYLON"]);
|
|
|
+})(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
|
|
|
+return /******/ (function(modules) { // webpackBootstrap
|
|
|
+/******/ // The module cache
|
|
|
+/******/ var installedModules = {};
|
|
|
+/******/
|
|
|
+/******/ // The require function
|
|
|
+/******/ function __webpack_require__(moduleId) {
|
|
|
+/******/
|
|
|
+/******/ // Check if module is in cache
|
|
|
+/******/ if(installedModules[moduleId]) {
|
|
|
+/******/ return installedModules[moduleId].exports;
|
|
|
+/******/ }
|
|
|
+/******/ // Create a new module (and put it into the cache)
|
|
|
+/******/ var module = installedModules[moduleId] = {
|
|
|
+/******/ i: moduleId,
|
|
|
+/******/ l: false,
|
|
|
+/******/ exports: {}
|
|
|
+/******/ };
|
|
|
+/******/
|
|
|
+/******/ // Execute the module function
|
|
|
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
|
+/******/
|
|
|
+/******/ // Flag the module as loaded
|
|
|
+/******/ module.l = true;
|
|
|
+/******/
|
|
|
+/******/ // Return the exports of the module
|
|
|
+/******/ return module.exports;
|
|
|
+/******/ }
|
|
|
+/******/
|
|
|
+/******/
|
|
|
+/******/ // expose the modules object (__webpack_modules__)
|
|
|
+/******/ __webpack_require__.m = modules;
|
|
|
+/******/
|
|
|
+/******/ // expose the module cache
|
|
|
+/******/ __webpack_require__.c = installedModules;
|
|
|
+/******/
|
|
|
+/******/ // define getter function for harmony exports
|
|
|
+/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
|
+/******/ if(!__webpack_require__.o(exports, name)) {
|
|
|
+/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
|
+/******/ }
|
|
|
+/******/ };
|
|
|
+/******/
|
|
|
+/******/ // define __esModule on exports
|
|
|
+/******/ __webpack_require__.r = function(exports) {
|
|
|
+/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
+/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
+/******/ }
|
|
|
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
+/******/ };
|
|
|
+/******/
|
|
|
+/******/ // create a fake namespace object
|
|
|
+/******/ // mode & 1: value is a module id, require it
|
|
|
+/******/ // mode & 2: merge all properties of value into the ns
|
|
|
+/******/ // mode & 4: return value when already ns object
|
|
|
+/******/ // mode & 8|1: behave like require
|
|
|
+/******/ __webpack_require__.t = function(value, mode) {
|
|
|
+/******/ if(mode & 1) value = __webpack_require__(value);
|
|
|
+/******/ if(mode & 8) return value;
|
|
|
+/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
|
+/******/ var ns = Object.create(null);
|
|
|
+/******/ __webpack_require__.r(ns);
|
|
|
+/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
|
+/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
|
+/******/ return ns;
|
|
|
+/******/ };
|
|
|
+/******/
|
|
|
+/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
+/******/ __webpack_require__.n = function(module) {
|
|
|
+/******/ var getter = module && module.__esModule ?
|
|
|
+/******/ function getDefault() { return module['default']; } :
|
|
|
+/******/ function getModuleExports() { return module; };
|
|
|
+/******/ __webpack_require__.d(getter, 'a', getter);
|
|
|
+/******/ return getter;
|
|
|
+/******/ };
|
|
|
+/******/
|
|
|
+/******/ // Object.prototype.hasOwnProperty.call
|
|
|
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
|
+/******/
|
|
|
+/******/ // __webpack_public_path__
|
|
|
+/******/ __webpack_require__.p = "";
|
|
|
+/******/
|
|
|
+/******/
|
|
|
+/******/ // Load entry module and return exports
|
|
|
+/******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-custom.ts");
|
|
|
+/******/ })
|
|
|
+/************************************************************************/
|
|
|
+/******/ ({
|
|
|
+
|
|
|
+/***/ "../node_modules/webpack/buildin/global.js":
|
|
|
+/*!*************************************************!*\
|
|
|
+ !*** ../node_modules/webpack/buildin/global.js ***!
|
|
|
+ \*************************************************/
|
|
|
+/*! no static exports found */
|
|
|
+/***/ (function(module, exports) {
|
|
|
+
|
|
|
+var g;
|
|
|
+
|
|
|
+// This works in non-strict mode
|
|
|
+g = (function() {
|
|
|
+ return this;
|
|
|
})();
|
|
|
-var BABYLON;
|
|
|
-(function (BABYLON) {
|
|
|
- var CustomShaderStructure = /** @class */ (function () {
|
|
|
- function CustomShaderStructure() {
|
|
|
- }
|
|
|
- return CustomShaderStructure;
|
|
|
- }());
|
|
|
- BABYLON.CustomShaderStructure = CustomShaderStructure;
|
|
|
- var ShaderSpecialParts = /** @class */ (function () {
|
|
|
- function ShaderSpecialParts() {
|
|
|
- }
|
|
|
- return ShaderSpecialParts;
|
|
|
- }());
|
|
|
- BABYLON.ShaderSpecialParts = ShaderSpecialParts;
|
|
|
- var CustomMaterial = /** @class */ (function (_super) {
|
|
|
- __extends(CustomMaterial, _super);
|
|
|
- function CustomMaterial(name, scene) {
|
|
|
- var _this = _super.call(this, name, scene) || this;
|
|
|
- _this.CustomParts = new ShaderSpecialParts();
|
|
|
- _this.customShaderNameResolve = _this.Builder;
|
|
|
- _this.FragmentShader = BABYLON.Effect.ShadersStore["defaultPixelShader"];
|
|
|
- _this.VertexShader = BABYLON.Effect.ShadersStore["defaultVertexShader"];
|
|
|
- return _this;
|
|
|
- }
|
|
|
- CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
|
|
|
- for (var el in this._newUniformInstances) {
|
|
|
- var ea = el.toString().split('-');
|
|
|
- if (ea[0] == 'vec2') {
|
|
|
- effect.setVector2(ea[1], this._newUniformInstances[el]);
|
|
|
- }
|
|
|
- else if (ea[0] == 'vec3') {
|
|
|
- effect.setVector3(ea[1], this._newUniformInstances[el]);
|
|
|
- }
|
|
|
- else if (ea[0] == 'vec4') {
|
|
|
- effect.setVector4(ea[1], this._newUniformInstances[el]);
|
|
|
- }
|
|
|
- else if (ea[0] == 'mat4') {
|
|
|
- effect.setMatrix(ea[1], this._newUniformInstances[el]);
|
|
|
- }
|
|
|
- else if (ea[0] == 'float') {
|
|
|
- effect.setFloat(ea[1], this._newUniformInstances[el]);
|
|
|
- }
|
|
|
- }
|
|
|
- for (var el in this._newSamplerInstances) {
|
|
|
- var ea = el.toString().split('-');
|
|
|
- if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
|
|
|
- effect.setTexture(ea[1], this._newSamplerInstances[el]);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- CustomMaterial.prototype.ReviewUniform = function (name, arr) {
|
|
|
- if (name == "uniform") {
|
|
|
- for (var ind in this._newUniforms) {
|
|
|
- if (this._customUniform[ind].indexOf('sampler') == -1) {
|
|
|
- arr.push(this._newUniforms[ind]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (name == "sampler") {
|
|
|
- for (var ind in this._newUniforms) {
|
|
|
- if (this._customUniform[ind].indexOf('sampler') != -1) {
|
|
|
- arr.push(this._newUniforms[ind]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return arr;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
|
|
|
- var _this = this;
|
|
|
- if (this._isCreatedShader) {
|
|
|
- return this._createdShaderName;
|
|
|
- }
|
|
|
- this._isCreatedShader = false;
|
|
|
- CustomMaterial.ShaderIndexer++;
|
|
|
- var name = "custom_" + CustomMaterial.ShaderIndexer;
|
|
|
- this.ReviewUniform("uniform", uniforms);
|
|
|
- this.ReviewUniform("sampler", samplers);
|
|
|
- var fn_afterBind = this._afterBind.bind(this);
|
|
|
- this._afterBind = function (m, e) {
|
|
|
- if (!e) {
|
|
|
- return;
|
|
|
- }
|
|
|
- _this.AttachAfterBind(m, e);
|
|
|
- try {
|
|
|
- fn_afterBind(m, e);
|
|
|
- }
|
|
|
- catch (e) { }
|
|
|
- };
|
|
|
- BABYLON.Effect.ShadersStore[name + "VertexShader"] = this.VertexShader
|
|
|
- .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
|
|
|
- .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
|
|
- .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
|
|
|
- .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
|
|
|
- .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""));
|
|
|
- // #define CUSTOM_VERTEX_MAIN_END
|
|
|
- BABYLON.Effect.ShadersStore[name + "PixelShader"] = this.FragmentShader
|
|
|
- .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
|
|
|
- .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
|
|
|
- .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
|
|
|
- .replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
|
|
|
- .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
|
|
|
- .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
|
|
|
- // #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
|
|
- // #define CUSTOM_FRAGMENT_BEFORE_FOG
|
|
|
- this._isCreatedShader = true;
|
|
|
- this._createdShaderName = name;
|
|
|
- return name;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.AddUniform = function (name, kind, param) {
|
|
|
- if (!this._customUniform) {
|
|
|
- this._customUniform = new Array();
|
|
|
- this._newUniforms = new Array();
|
|
|
- this._newSamplerInstances = new Array();
|
|
|
- this._newUniformInstances = new Array();
|
|
|
- }
|
|
|
- if (param) {
|
|
|
- if (kind.indexOf("sampler") == -1) {
|
|
|
- this._newUniformInstances[kind + "-" + name] = param;
|
|
|
- }
|
|
|
- else {
|
|
|
- this._newUniformInstances[kind + "-" + name] = param;
|
|
|
- }
|
|
|
- }
|
|
|
- this._customUniform.push("uniform " + kind + " " + name + ";");
|
|
|
- this._newUniforms.push(name);
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_Begin = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_Definitions = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_MainBegin = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
|
|
|
- this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
|
|
|
- this.CustomParts.Vertex_Begin = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
|
|
|
- this.CustomParts.Vertex_Definitions = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
|
|
|
- this.CustomParts.Vertex_MainBegin = shaderPart;
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
|
|
|
- this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
|
|
|
- this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
|
|
|
- return this;
|
|
|
- };
|
|
|
- CustomMaterial.ShaderIndexer = 1;
|
|
|
- return CustomMaterial;
|
|
|
- }(BABYLON.StandardMaterial));
|
|
|
- BABYLON.CustomMaterial = CustomMaterial;
|
|
|
-})(BABYLON || (BABYLON = {}));
|
|
|
-
|
|
|
-//# sourceMappingURL=babylon.customMaterial.js.map
|
|
|
+
|
|
|
+try {
|
|
|
+ // This works if eval is allowed (see CSP)
|
|
|
+ g = g || Function("return this")() || (1, eval)("this");
|
|
|
+} catch (e) {
|
|
|
+ // This works if the window reference is available
|
|
|
+ if (typeof window === "object") g = window;
|
|
|
+}
|
|
|
+
|
|
|
+// g can still be undefined, but nothing to do about it...
|
|
|
+// We return undefined, instead of nothing here, so it's
|
|
|
+// easier to handle this case. if(!global) { ...}
|
|
|
+
|
|
|
+module.exports = g;
|
|
|
+
|
|
|
+
|
|
|
+/***/ }),
|
|
|
+
|
|
|
+/***/ "./legacy/legacy-custom.ts":
|
|
|
+/*!*********************************!*\
|
|
|
+ !*** ./legacy/legacy-custom.ts ***!
|
|
|
+ \*********************************/
|
|
|
+/*! no static exports found */
|
|
|
+/***/ (function(module, exports, __webpack_require__) {
|
|
|
+
|
|
|
+"use strict";
|
|
|
+/* WEBPACK VAR INJECTION */(function(global) {
|
|
|
+function __export(m) {
|
|
|
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
|
+}
|
|
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
+var MatLib = __webpack_require__(/*! ../src/custom/index */ "./src/custom/index.ts");
|
|
|
+/**
|
|
|
+ * This is the entry point for the UMD module.
|
|
|
+ * The entry point for a future ESM package should be index.ts
|
|
|
+ */
|
|
|
+var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
|
|
|
+if (typeof globalObject !== "undefined") {
|
|
|
+ for (var key in MatLib) {
|
|
|
+ globalObject.BABYLON[key] = MatLib[key];
|
|
|
+ }
|
|
|
+}
|
|
|
+__export(__webpack_require__(/*! ../src/custom/index */ "./src/custom/index.ts"));
|
|
|
+
|
|
|
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
|
|
|
+
|
|
|
+/***/ }),
|
|
|
+
|
|
|
+/***/ "./src/custom/customMaterial.ts":
|
|
|
+/*!**************************************!*\
|
|
|
+ !*** ./src/custom/customMaterial.ts ***!
|
|
|
+ \**************************************/
|
|
|
+/*! no static exports found */
|
|
|
+/***/ (function(module, exports, __webpack_require__) {
|
|
|
+
|
|
|
+"use strict";
|
|
|
+
|
|
|
+var __extends = (this && this.__extends) || (function () {
|
|
|
+ var extendStatics = function (d, b) {
|
|
|
+ extendStatics = Object.setPrototypeOf ||
|
|
|
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
+ return extendStatics(d, b);
|
|
|
+ }
|
|
|
+ return function (d, b) {
|
|
|
+ extendStatics(d, b);
|
|
|
+ function __() { this.constructor = d; }
|
|
|
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
+ };
|
|
|
+})();
|
|
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
+var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
|
|
|
+var CustomShaderStructure = /** @class */ (function () {
|
|
|
+ function CustomShaderStructure() {
|
|
|
+ }
|
|
|
+ return CustomShaderStructure;
|
|
|
+}());
|
|
|
+exports.CustomShaderStructure = CustomShaderStructure;
|
|
|
+var ShaderSpecialParts = /** @class */ (function () {
|
|
|
+ function ShaderSpecialParts() {
|
|
|
+ }
|
|
|
+ return ShaderSpecialParts;
|
|
|
+}());
|
|
|
+exports.ShaderSpecialParts = ShaderSpecialParts;
|
|
|
+var CustomMaterial = /** @class */ (function (_super) {
|
|
|
+ __extends(CustomMaterial, _super);
|
|
|
+ function CustomMaterial(name, scene) {
|
|
|
+ var _this = _super.call(this, name, scene) || this;
|
|
|
+ _this.CustomParts = new ShaderSpecialParts();
|
|
|
+ _this.customShaderNameResolve = _this.Builder;
|
|
|
+ _this.FragmentShader = BABYLON.Effect.ShadersStore["defaultPixelShader"];
|
|
|
+ _this.VertexShader = BABYLON.Effect.ShadersStore["defaultVertexShader"];
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
|
|
|
+ for (var el in this._newUniformInstances) {
|
|
|
+ var ea = el.toString().split('-');
|
|
|
+ if (ea[0] == 'vec2') {
|
|
|
+ effect.setVector2(ea[1], this._newUniformInstances[el]);
|
|
|
+ }
|
|
|
+ else if (ea[0] == 'vec3') {
|
|
|
+ effect.setVector3(ea[1], this._newUniformInstances[el]);
|
|
|
+ }
|
|
|
+ else if (ea[0] == 'vec4') {
|
|
|
+ effect.setVector4(ea[1], this._newUniformInstances[el]);
|
|
|
+ }
|
|
|
+ else if (ea[0] == 'mat4') {
|
|
|
+ effect.setMatrix(ea[1], this._newUniformInstances[el]);
|
|
|
+ }
|
|
|
+ else if (ea[0] == 'float') {
|
|
|
+ effect.setFloat(ea[1], this._newUniformInstances[el]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var el in this._newSamplerInstances) {
|
|
|
+ var ea = el.toString().split('-');
|
|
|
+ if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
|
|
|
+ effect.setTexture(ea[1], this._newSamplerInstances[el]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.ReviewUniform = function (name, arr) {
|
|
|
+ if (name == "uniform") {
|
|
|
+ for (var ind in this._newUniforms) {
|
|
|
+ if (this._customUniform[ind].indexOf('sampler') == -1) {
|
|
|
+ arr.push(this._newUniforms[ind]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (name == "sampler") {
|
|
|
+ for (var ind in this._newUniforms) {
|
|
|
+ if (this._customUniform[ind].indexOf('sampler') != -1) {
|
|
|
+ arr.push(this._newUniforms[ind]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
|
|
|
+ var _this = this;
|
|
|
+ if (this._isCreatedShader) {
|
|
|
+ return this._createdShaderName;
|
|
|
+ }
|
|
|
+ this._isCreatedShader = false;
|
|
|
+ CustomMaterial.ShaderIndexer++;
|
|
|
+ var name = "custom_" + CustomMaterial.ShaderIndexer;
|
|
|
+ this.ReviewUniform("uniform", uniforms);
|
|
|
+ this.ReviewUniform("sampler", samplers);
|
|
|
+ var fn_afterBind = this._afterBind.bind(this);
|
|
|
+ this._afterBind = function (m, e) {
|
|
|
+ if (!e) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _this.AttachAfterBind(m, e);
|
|
|
+ try {
|
|
|
+ fn_afterBind(m, e);
|
|
|
+ }
|
|
|
+ catch (e) { }
|
|
|
+ };
|
|
|
+ BABYLON.Effect.ShadersStore[name + "VertexShader"] = this.VertexShader
|
|
|
+ .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
|
|
|
+ .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
|
|
+ .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
|
|
|
+ .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
|
|
|
+ .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""));
|
|
|
+ // #define CUSTOM_VERTEX_MAIN_END
|
|
|
+ BABYLON.Effect.ShadersStore[name + "PixelShader"] = this.FragmentShader
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
|
|
|
+ .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
|
|
|
+ // #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
|
|
+ // #define CUSTOM_FRAGMENT_BEFORE_FOG
|
|
|
+ this._isCreatedShader = true;
|
|
|
+ this._createdShaderName = name;
|
|
|
+ return name;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.AddUniform = function (name, kind, param) {
|
|
|
+ if (!this._customUniform) {
|
|
|
+ this._customUniform = new Array();
|
|
|
+ this._newUniforms = new Array();
|
|
|
+ this._newSamplerInstances = new Array();
|
|
|
+ this._newUniformInstances = new Array();
|
|
|
+ }
|
|
|
+ if (param) {
|
|
|
+ if (kind.indexOf("sampler") == -1) {
|
|
|
+ this._newUniformInstances[kind + "-" + name] = param;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._newUniformInstances[kind + "-" + name] = param;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._customUniform.push("uniform " + kind + " " + name + ";");
|
|
|
+ this._newUniforms.push(name);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_Begin = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_Definitions = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_MainBegin = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
|
|
|
+ this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
|
|
|
+ this.CustomParts.Vertex_Begin = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
|
|
|
+ this.CustomParts.Vertex_Definitions = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
|
|
|
+ this.CustomParts.Vertex_MainBegin = shaderPart;
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
|
|
|
+ this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
|
|
|
+ this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ CustomMaterial.ShaderIndexer = 1;
|
|
|
+ return CustomMaterial;
|
|
|
+}(babylonjs_1.StandardMaterial));
|
|
|
+exports.CustomMaterial = CustomMaterial;
|
|
|
+
|
|
|
+
|
|
|
+/***/ }),
|
|
|
+
|
|
|
+/***/ "./src/custom/index.ts":
|
|
|
+/*!*****************************!*\
|
|
|
+ !*** ./src/custom/index.ts ***!
|
|
|
+ \*****************************/
|
|
|
+/*! no static exports found */
|
|
|
+/***/ (function(module, exports, __webpack_require__) {
|
|
|
+
|
|
|
+"use strict";
|
|
|
+
|
|
|
+function __export(m) {
|
|
|
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
|
+}
|
|
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
+__export(__webpack_require__(/*! ./customMaterial */ "./src/custom/customMaterial.ts"));
|
|
|
+
|
|
|
+
|
|
|
+/***/ }),
|
|
|
+
|
|
|
+/***/ "babylonjs":
|
|
|
+/*!****************************************************************************************************!*\
|
|
|
+ !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
|
|
|
+ \****************************************************************************************************/
|
|
|
+/*! no static exports found */
|
|
|
+/***/ (function(module, exports) {
|
|
|
+
|
|
|
+module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
|
|
|
+
|
|
|
+/***/ })
|
|
|
+
|
|
|
+/******/ });
|
|
|
+});
|
|
|
+//# sourceMappingURL=babylon.customMaterial.js.map
|