|
@@ -22387,6 +22387,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateBox = function (name, options, scene) {
|
|
|
var box = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ box.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateBox(options);
|
|
|
vertexData.applyToMesh(box, options.updatable);
|
|
|
return box;
|
|
@@ -22406,6 +22407,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateSphere = function (name, options, scene) {
|
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ sphere.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateSphere(options);
|
|
|
vertexData.applyToMesh(sphere, options.updatable);
|
|
|
return sphere;
|
|
@@ -22423,6 +22425,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateDisc = function (name, options, scene) {
|
|
|
var disc = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ disc.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateDisc(options);
|
|
|
vertexData.applyToMesh(disc, options.updatable);
|
|
|
return disc;
|
|
@@ -22441,6 +22444,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateIcoSphere = function (name, options, scene) {
|
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ sphere.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateIcoSphere(options);
|
|
|
vertexData.applyToMesh(sphere, options.updatable);
|
|
|
return sphere;
|
|
@@ -22590,6 +22594,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateCylinder = function (name, options, scene) {
|
|
|
var cylinder = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ cylinder.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateCylinder(options);
|
|
|
vertexData.applyToMesh(cylinder, options.updatable);
|
|
|
return cylinder;
|
|
@@ -22607,6 +22612,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateTorus = function (name, options, scene) {
|
|
|
var torus = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ torus.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateTorus(options);
|
|
|
vertexData.applyToMesh(torus, options.updatable);
|
|
|
return torus;
|
|
@@ -22625,6 +22631,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreateTorusKnot = function (name, options, scene) {
|
|
|
var torusKnot = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ torusKnot.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreateTorusKnot(options);
|
|
|
vertexData.applyToMesh(torusKnot, options.updatable);
|
|
|
return torusKnot;
|
|
@@ -22900,6 +22907,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreatePlane = function (name, options, scene) {
|
|
|
var plane = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ plane.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreatePlane(options);
|
|
|
vertexData.applyToMesh(plane, options.updatable);
|
|
|
if (options.sourcePlane) {
|
|
@@ -23152,6 +23160,7 @@ var BABYLON;
|
|
|
MeshBuilder.CreatePolyhedron = function (name, options, scene) {
|
|
|
var polyhedron = new BABYLON.Mesh(name, scene);
|
|
|
options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene);
|
|
|
+ polyhedron.sideOrientation = options.sideOrientation;
|
|
|
var vertexData = BABYLON.VertexData.CreatePolyhedron(options);
|
|
|
vertexData.applyToMesh(polyhedron, options.updatable);
|
|
|
return polyhedron;
|
|
@@ -25246,10 +25255,10 @@ var BABYLON;
|
|
|
return this._compilationError;
|
|
|
};
|
|
|
Effect.prototype.getVertexShaderSource = function () {
|
|
|
- return this._engine.getVertexShaderSource(this._program);
|
|
|
+ return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program));
|
|
|
};
|
|
|
Effect.prototype.getFragmentShaderSource = function () {
|
|
|
- return this._engine.getFragmentShaderSource(this._program);
|
|
|
+ return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program));
|
|
|
};
|
|
|
// Methods
|
|
|
Effect.prototype._loadVertexShader = function (vertex, callback) {
|
|
@@ -25691,6 +25700,98 @@ var BABYLON;
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
+ Effect.prototype._recombineShader = function (node) {
|
|
|
+ if (node.define) {
|
|
|
+ if (node.condition) {
|
|
|
+ }
|
|
|
+ else if (node.ndef) {
|
|
|
+ if (this.defines.indexOf("#define " + node.define) !== -1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (this.defines.indexOf("#define " + node.define) === -1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var result = "";
|
|
|
+ for (var index = 0; index < node.children.length; index++) {
|
|
|
+ var line = node.children[index];
|
|
|
+ if (line.children) {
|
|
|
+ var combined = this._recombineShader(line) + "\r\n";
|
|
|
+ if (combined !== null) {
|
|
|
+ result += combined + "\r\n";
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ result += line + "\r\n";
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ Effect.prototype._evaluateDefinesOnString = function (shaderString) {
|
|
|
+ var root = {
|
|
|
+ children: []
|
|
|
+ };
|
|
|
+ var currentNode = root;
|
|
|
+ var lines = shaderString.split("\n");
|
|
|
+ for (var index = 0; index < lines.length; index++) {
|
|
|
+ var line = lines[index].trim();
|
|
|
+ // #ifdef
|
|
|
+ var pos = line.indexOf("#ifdef ");
|
|
|
+ if (pos !== -1) {
|
|
|
+ var define = line.substr(pos + 7);
|
|
|
+ var newNode = {
|
|
|
+ condition: null,
|
|
|
+ ndef: false,
|
|
|
+ define: define,
|
|
|
+ children: [],
|
|
|
+ parent: currentNode
|
|
|
+ };
|
|
|
+ currentNode.children.push(newNode);
|
|
|
+ currentNode = newNode;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // #ifndef
|
|
|
+ var pos = line.indexOf("#ifndef ");
|
|
|
+ if (pos !== -1) {
|
|
|
+ var define = line.substr(pos + 8);
|
|
|
+ newNode = {
|
|
|
+ condition: null,
|
|
|
+ define: define,
|
|
|
+ ndef: true,
|
|
|
+ children: [],
|
|
|
+ parent: currentNode
|
|
|
+ };
|
|
|
+ currentNode.children.push(newNode);
|
|
|
+ currentNode = newNode;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // #if
|
|
|
+ var pos = line.indexOf("#if ");
|
|
|
+ if (pos !== -1) {
|
|
|
+ var define = line.substr(pos + 4).trim();
|
|
|
+ var conditionPos = define.indexOf(" ");
|
|
|
+ newNode = {
|
|
|
+ condition: define.substr(conditionPos + 1),
|
|
|
+ define: define.substr(0, conditionPos),
|
|
|
+ ndef: false,
|
|
|
+ children: [],
|
|
|
+ parent: currentNode
|
|
|
+ };
|
|
|
+ currentNode.children.push(newNode);
|
|
|
+ currentNode = newNode;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+ pos = line.indexOf("#endif");
|
|
|
+ if (pos !== -1) {
|
|
|
+ currentNode = currentNode.parent;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ currentNode.children.push(line);
|
|
|
+ }
|
|
|
+ // Recombine
|
|
|
+ return this._recombineShader(root);
|
|
|
+ };
|
|
|
// Statics
|
|
|
Effect.ShadersStore = {};
|
|
|
Effect.IncludesShadersStore = {};
|