|
@@ -5309,7 +5309,7 @@ var BABYLON;
|
|
scene.activeCamera = camera;
|
|
scene.activeCamera = camera;
|
|
}
|
|
}
|
|
//At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
|
|
//At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
|
|
- var texture = new BABYLON.RenderTargetTexture("screenShot", size, scene, false, false);
|
|
|
|
|
|
+ var texture = new BABYLON.RenderTargetTexture("screenShot", size, scene, false, false, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
|
|
texture.renderList = scene.meshes;
|
|
texture.renderList = scene.meshes;
|
|
texture.onAfterRenderObservable.add(function () {
|
|
texture.onAfterRenderObservable.add(function () {
|
|
Tools.DumpFramebuffer(width, height, engine, successCallback, mimeType);
|
|
Tools.DumpFramebuffer(width, height, engine, successCallback, mimeType);
|
|
@@ -19224,19 +19224,28 @@ var BABYLON;
|
|
mesh.physicsImpostor = null;
|
|
mesh.physicsImpostor = null;
|
|
};
|
|
};
|
|
// Misc.
|
|
// Misc.
|
|
- Scene.prototype.createDefaultCameraOrLight = function () {
|
|
|
|
|
|
+ Scene.prototype.createDefaultCameraOrLight = function (createArcRotateCamera) {
|
|
|
|
+ if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
|
|
// Light
|
|
// Light
|
|
if (this.lights.length === 0) {
|
|
if (this.lights.length === 0) {
|
|
new BABYLON.HemisphericLight("default light", BABYLON.Vector3.Up(), this);
|
|
new BABYLON.HemisphericLight("default light", BABYLON.Vector3.Up(), this);
|
|
}
|
|
}
|
|
// Camera
|
|
// Camera
|
|
if (!this.activeCamera) {
|
|
if (!this.activeCamera) {
|
|
- var camera = new BABYLON.FreeCamera("default camera", BABYLON.Vector3.Zero(), this);
|
|
|
|
// Compute position
|
|
// Compute position
|
|
var worldExtends = this.getWorldExtends();
|
|
var worldExtends = this.getWorldExtends();
|
|
var worldCenter = worldExtends.min.add(worldExtends.max.subtract(worldExtends.min).scale(0.5));
|
|
var worldCenter = worldExtends.min.add(worldExtends.max.subtract(worldExtends.min).scale(0.5));
|
|
- camera.position = new BABYLON.Vector3(worldCenter.x, worldCenter.y, worldExtends.min.z - (worldExtends.max.z - worldExtends.min.z));
|
|
|
|
- camera.setTarget(worldCenter);
|
|
|
|
|
|
+ var camera;
|
|
|
|
+ if (createArcRotateCamera) {
|
|
|
|
+ camera = new BABYLON.ArcRotateCamera("default camera", 0, 0, 10, BABYLON.Vector3.Zero(), this);
|
|
|
|
+ camera.setPosition(new BABYLON.Vector3(worldCenter.x, worldCenter.y, worldExtends.min.z - (worldExtends.max.z - worldExtends.min.z)));
|
|
|
|
+ camera.setTarget(worldCenter);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ camera = new BABYLON.FreeCamera("default camera", BABYLON.Vector3.Zero(), this);
|
|
|
|
+ camera.position = new BABYLON.Vector3(worldCenter.x, worldCenter.y, worldExtends.min.z - (worldExtends.max.z - worldExtends.min.z));
|
|
|
|
+ camera.setTarget(worldCenter);
|
|
|
|
+ }
|
|
this.activeCamera = camera;
|
|
this.activeCamera = camera;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -25246,10 +25255,10 @@ var BABYLON;
|
|
return this._compilationError;
|
|
return this._compilationError;
|
|
};
|
|
};
|
|
Effect.prototype.getVertexShaderSource = function () {
|
|
Effect.prototype.getVertexShaderSource = function () {
|
|
- return this._engine.getVertexShaderSource(this._program);
|
|
|
|
|
|
+ return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program));
|
|
};
|
|
};
|
|
Effect.prototype.getFragmentShaderSource = function () {
|
|
Effect.prototype.getFragmentShaderSource = function () {
|
|
- return this._engine.getFragmentShaderSource(this._program);
|
|
|
|
|
|
+ return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program));
|
|
};
|
|
};
|
|
// Methods
|
|
// Methods
|
|
Effect.prototype._loadVertexShader = function (vertex, callback) {
|
|
Effect.prototype._loadVertexShader = function (vertex, callback) {
|
|
@@ -25691,6 +25700,98 @@ var BABYLON;
|
|
}
|
|
}
|
|
return this;
|
|
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
|
|
// Statics
|
|
Effect.ShadersStore = {};
|
|
Effect.ShadersStore = {};
|
|
Effect.IncludesShadersStore = {};
|
|
Effect.IncludesShadersStore = {};
|