|
@@ -9514,7 +9514,7 @@ var BABYLON;
|
|
|
this._localPivotScaling.multiplyToRef(this._localRotation, this._localPivotScalingRotation);
|
|
|
|
|
|
|
|
|
- if (this.billboardMode !== AbstractMesh.BILLBOARDMODE_NONE) {
|
|
|
+ if (this.billboardMode !== AbstractMesh.BILLBOARDMODE_NONE && this.getScene().activeCamera) {
|
|
|
var localPosition = this.position.clone();
|
|
|
var zero = this.getScene().activeCamera.position.clone();
|
|
|
|
|
@@ -15884,9 +15884,14 @@ var BABYLON;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- var effect = postProcesses[postProcessesTakenIndices[index]].apply();
|
|
|
+ var pp = postProcesses[postProcessesTakenIndices[index]];
|
|
|
+ var effect = pp.apply();
|
|
|
|
|
|
if (effect) {
|
|
|
+ if (pp.onBeforeRender) {
|
|
|
+ pp.onBeforeRender(effect);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
|
|
|
|
|
@@ -18265,7 +18270,54 @@ var BABYLON;
|
|
|
};
|
|
|
|
|
|
var parseCamera = function (parsedCamera, scene) {
|
|
|
- var camera = new BABYLON.FreeCamera(parsedCamera.name, BABYLON.Vector3.FromArray(parsedCamera.position), scene);
|
|
|
+ var camera;
|
|
|
+ var position = BABYLON.Vector3.FromArray(parsedCamera.position);
|
|
|
+ var lockedTargetMesh = (parsedCamera.lockedTargetId) ? scene.getLastMeshByID(parsedCamera.lockedTargetId) : null;
|
|
|
+
|
|
|
+ if (parsedCamera.type === "AnaglyphArcRotateCamera" || parsedCamera.type === "ArcRotateCamera") {
|
|
|
+ var alpha = parsedCamera.alpha;
|
|
|
+ var beta = parsedCamera.beta;
|
|
|
+ var radius = parsedCamera.radius;
|
|
|
+ if (parsedCamera.type === "AnaglyphArcRotateCamera") {
|
|
|
+ var eye_space = parsedCamera.eye_space;
|
|
|
+ camera = new BABYLON.AnaglyphArcRotateCamera(parsedCamera.name, alpha, beta, radius, lockedTargetMesh, eye_space, scene);
|
|
|
+ } else {
|
|
|
+ camera = new BABYLON.ArcRotateCamera(parsedCamera.name, alpha, beta, radius, lockedTargetMesh, scene);
|
|
|
+ }
|
|
|
+ } else if (parsedCamera.type === "AnaglyphFreeCamera") {
|
|
|
+ var eye_space = parsedCamera.eye_space;
|
|
|
+ camera = new BABYLON.AnaglyphFreeCamera(parsedCamera.name, position, eye_space, scene);
|
|
|
+ } else if (parsedCamera.type === "DeviceOrientationCamera") {
|
|
|
+ camera = new BABYLON.DeviceOrientationCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "FollowCamera") {
|
|
|
+ camera = new BABYLON.FollowCamera(parsedCamera.name, position, scene);
|
|
|
+ camera.heightOffset = parsedCamera.heightOffset;
|
|
|
+ camera.radius = parsedCamera.radius;
|
|
|
+ camera.rotationOffset = parsedCamera.rotationOffset;
|
|
|
+ if (lockedTargetMesh)
|
|
|
+ camera.target = lockedTargetMesh;
|
|
|
+ } else if (parsedCamera.type === "GamepadCamera") {
|
|
|
+ camera = new BABYLON.GamepadCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "OculusCamera") {
|
|
|
+ camera = new BABYLON.OculusCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "TouchCamera") {
|
|
|
+ camera = new BABYLON.TouchCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "VirtualJoysticksCamera") {
|
|
|
+ camera = new BABYLON.VirtualJoysticksCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "WebVRCamera") {
|
|
|
+ camera = new BABYLON.WebVRCamera(parsedCamera.name, position, scene);
|
|
|
+ } else if (parsedCamera.type === "VRDeviceOrientationCamera") {
|
|
|
+ camera = new BABYLON.VRDeviceOrientationCamera(parsedCamera.name, position, scene);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ camera = new BABYLON.FreeCamera(parsedCamera.name, position, scene);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (lockedTargetMesh && camera instanceof BABYLON.FreeCamera) {
|
|
|
+ camera.lockedTarget = lockedTargetMesh;
|
|
|
+ }
|
|
|
+
|
|
|
camera.id = parsedCamera.id;
|
|
|
|
|
|
BABYLON.Tags.AddTagsTo(camera, parsedCamera.tags);
|
|
@@ -18282,11 +18334,6 @@ var BABYLON;
|
|
|
camera.rotation = BABYLON.Vector3.FromArray(parsedCamera.rotation);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (parsedCamera.lockedTargetId) {
|
|
|
- camera._waitingLockedTargetId = parsedCamera.lockedTargetId;
|
|
|
- }
|
|
|
-
|
|
|
camera.fov = parsedCamera.fov;
|
|
|
camera.minZ = parsedCamera.minZ;
|
|
|
camera.maxZ = parsedCamera.maxZ;
|
|
@@ -18510,7 +18557,7 @@ var BABYLON;
|
|
|
|
|
|
|
|
|
if (parsedMesh.parentId) {
|
|
|
- mesh.parent = scene.getLastEntryByID(parsedMesh.parentId);
|
|
|
+ mesh._waitingParentId = parsedMesh.parentId;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -18901,6 +18948,14 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ for (index = 0; index < scene.meshes.length; index++) {
|
|
|
+ var currentMesh = scene.meshes[index];
|
|
|
+ if (currentMesh._waitingParentId) {
|
|
|
+ currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
|
|
|
+ currentMesh._waitingParentId = undefined;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (parsedData.particleSystems) {
|
|
|
for (index = 0; index < parsedData.particleSystems.length; index++) {
|
|
@@ -18938,15 +18993,6 @@ var BABYLON;
|
|
|
parseLight(parsedLight, scene);
|
|
|
}
|
|
|
|
|
|
- for (index = 0; index < parsedData.cameras.length; index++) {
|
|
|
- var parsedCamera = parsedData.cameras[index];
|
|
|
- parseCamera(parsedCamera, scene);
|
|
|
- }
|
|
|
-
|
|
|
- if (parsedData.activeCameraID) {
|
|
|
- scene.setActiveCameraByID(parsedData.activeCameraID);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
if (parsedData.materials) {
|
|
|
for (index = 0; index < parsedData.materials.length; index++) {
|
|
@@ -19051,19 +19097,28 @@ var BABYLON;
|
|
|
parseMesh(parsedMesh, scene, rootUrl);
|
|
|
}
|
|
|
|
|
|
+ for (index = 0; index < parsedData.cameras.length; index++) {
|
|
|
+ var parsedCamera = parsedData.cameras[index];
|
|
|
+ parseCamera(parsedCamera, scene);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parsedData.activeCameraID) {
|
|
|
+ scene.setActiveCameraByID(parsedData.activeCameraID);
|
|
|
+ }
|
|
|
+
|
|
|
for (index = 0; index < scene.cameras.length; index++) {
|
|
|
var camera = scene.cameras[index];
|
|
|
if (camera._waitingParentId) {
|
|
|
camera.parent = scene.getLastEntryByID(camera._waitingParentId);
|
|
|
- delete camera._waitingParentId;
|
|
|
+ camera._waitingParentId = undefined;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (camera instanceof BABYLON.FreeCamera) {
|
|
|
- var freecamera = camera;
|
|
|
- if (freecamera._waitingLockedTargetId) {
|
|
|
- freecamera.lockedTarget = scene.getLastEntryByID(freecamera._waitingLockedTargetId);
|
|
|
- delete freecamera._waitingLockedTargetId;
|
|
|
- }
|
|
|
+ for (index = 0; index < scene.meshes.length; index++) {
|
|
|
+ var mesh = scene.meshes[index];
|
|
|
+ if (mesh._waitingParentId) {
|
|
|
+ mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
|
|
|
+ mesh._waitingParentId = undefined;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -21765,14 +21820,13 @@ var BABYLON;
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
var PostProcessRenderEffect = (function () {
|
|
|
- function PostProcessRenderEffect(engine, name, postProcessType, ratio, samplingMode, singleInstance) {
|
|
|
+ function PostProcessRenderEffect(engine, name, getPostProcess, singleInstance) {
|
|
|
this._engine = engine;
|
|
|
this._name = name;
|
|
|
- this._postProcessType = postProcessType;
|
|
|
- this._ratio = ratio || 1.0;
|
|
|
- this._samplingMode = samplingMode || null;
|
|
|
this._singleInstance = singleInstance || true;
|
|
|
|
|
|
+ this._getPostProcess = getPostProcess;
|
|
|
+
|
|
|
this._cameras = [];
|
|
|
|
|
|
this._postProcesses = [];
|
|
@@ -21780,64 +21834,7 @@ var BABYLON;
|
|
|
|
|
|
this._renderPasses = [];
|
|
|
this._renderEffectAsPasses = [];
|
|
|
-
|
|
|
- this.parameters = function (effect) {
|
|
|
- };
|
|
|
}
|
|
|
- PostProcessRenderEffect._GetInstance = function (engine, postProcessType, ratio, samplingMode) {
|
|
|
- var postProcess;
|
|
|
- var instance;
|
|
|
- var args = [];
|
|
|
-
|
|
|
- var parameters = PostProcessRenderEffect._GetParametersNames(postProcessType);
|
|
|
- for (var i = 0; i < parameters.length; i++) {
|
|
|
- switch (parameters[i]) {
|
|
|
- case "name":
|
|
|
- args[i] = postProcessType.toString();
|
|
|
- break;
|
|
|
- case "ratio":
|
|
|
- args[i] = ratio;
|
|
|
- break;
|
|
|
- case "camera":
|
|
|
- args[i] = null;
|
|
|
- break;
|
|
|
- case "samplingMode":
|
|
|
- args[i] = samplingMode;
|
|
|
- break;
|
|
|
- case "engine":
|
|
|
- args[i] = engine;
|
|
|
- break;
|
|
|
- case "reusable":
|
|
|
- args[i] = true;
|
|
|
- break;
|
|
|
- default:
|
|
|
- args[i] = null;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- postProcess = function () {
|
|
|
- };
|
|
|
- postProcess.prototype = postProcessType.prototype;
|
|
|
-
|
|
|
- instance = new postProcess();
|
|
|
- postProcessType.apply(instance, args);
|
|
|
-
|
|
|
- return instance;
|
|
|
- };
|
|
|
-
|
|
|
- PostProcessRenderEffect._GetParametersNames = function (func) {
|
|
|
- var commentsRegex = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
|
|
|
- var functWithoutComments = func.toString().replace(commentsRegex, '');
|
|
|
-
|
|
|
- var parameters = functWithoutComments.slice(functWithoutComments.indexOf('(') + 1, functWithoutComments.indexOf(')')).match(/([^\s,]+)/g);
|
|
|
-
|
|
|
- if (parameters === null)
|
|
|
- parameters = [];
|
|
|
-
|
|
|
- return parameters;
|
|
|
- };
|
|
|
-
|
|
|
PostProcessRenderEffect.prototype._update = function () {
|
|
|
for (var renderPassName in this._renderPasses) {
|
|
|
this._renderPasses[renderPassName]._update();
|
|
@@ -21891,11 +21888,11 @@ var BABYLON;
|
|
|
cameraKey = cameraName;
|
|
|
}
|
|
|
|
|
|
- this._postProcesses[cameraKey] = this._postProcesses[cameraKey] || PostProcessRenderEffect._GetInstance(this._engine, this._postProcessType, this._ratio, this._samplingMode);
|
|
|
+ this._postProcesses[cameraKey] = this._postProcesses[cameraKey] || this._getPostProcess();
|
|
|
|
|
|
var index = camera.attachPostProcess(this._postProcesses[cameraKey]);
|
|
|
|
|
|
- if (this._indicesForCamera[cameraName] === null) {
|
|
|
+ if (!this._indicesForCamera[cameraName]) {
|
|
|
this._indicesForCamera[cameraName] = [];
|
|
|
}
|
|
|
|
|
@@ -21978,8 +21975,11 @@ var BABYLON;
|
|
|
PostProcessRenderEffect.prototype._linkParameters = function () {
|
|
|
var _this = this;
|
|
|
for (var index in this._postProcesses) {
|
|
|
- this._postProcesses[index].onApply = function (effect) {
|
|
|
- _this.parameters(effect);
|
|
|
+ if (this.applyParameters) {
|
|
|
+ this.applyParameters(this._postProcesses[index]);
|
|
|
+ }
|
|
|
+
|
|
|
+ this._postProcesses[index].onBeforeRender = function (effect) {
|
|
|
_this._linkTextures(effect);
|
|
|
};
|
|
|
}
|
|
@@ -22021,7 +22021,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderEffects.enable(BABYLON.Tools.MakeArray(cameras || this._cameras));
|
|
|
+ renderEffects._enable(BABYLON.Tools.MakeArray(cameras || this._cameras));
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
|
|
@@ -22031,7 +22031,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderEffects.disable(BABYLON.Tools.MakeArray(cameras || this._cameras));
|
|
|
+ renderEffects._disable(BABYLON.Tools.MakeArray(cameras || this._cameras));
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
|
|
@@ -22072,6 +22072,7 @@ var BABYLON;
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipeline.prototype._enableDisplayOnlyPass = function (passName, cameras) {
|
|
|
+ var _this = this;
|
|
|
var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
|
|
|
|
|
|
var pass = null;
|
|
@@ -22098,7 +22099,9 @@ var BABYLON;
|
|
|
var camera = _cam[i];
|
|
|
var cameraName = camera.name;
|
|
|
|
|
|
- this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, "BABYLON.DisplayPassPostProcess", 1.0, null, null);
|
|
|
+ this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () {
|
|
|
+ return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true);
|
|
|
+ });
|
|
|
this._renderEffectsForIsolatedPass[cameraName].emptyPasses();
|
|
|
this._renderEffectsForIsolatedPass[cameraName].addPass(pass);
|
|
|
this._renderEffectsForIsolatedPass[cameraName]._attachCameras(camera);
|
|
@@ -22106,13 +22109,16 @@ var BABYLON;
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipeline.prototype._disableDisplayOnlyPass = function (cameras) {
|
|
|
+ var _this = this;
|
|
|
var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
|
|
|
|
|
|
for (var i = 0; i < _cam.length; i++) {
|
|
|
var camera = _cam[i];
|
|
|
var cameraName = camera.name;
|
|
|
|
|
|
- this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, "BABYLON.DisplayPassPostProcess", 1.0, null, null);
|
|
|
+ this._renderEffectsForIsolatedPass[cameraName] = this._renderEffectsForIsolatedPass[cameraName] || new BABYLON.PostProcessRenderEffect(this._engine, PostProcessRenderPipeline.PASS_EFFECT_NAME, function () {
|
|
|
+ return new BABYLON.DisplayPassPostProcess(PostProcessRenderPipeline.PASS_EFFECT_NAME, 1.0, null, null, _this._engine, true);
|
|
|
+ });
|
|
|
this._renderEffectsForIsolatedPass[cameraName]._disable(camera);
|
|
|
}
|
|
|
|
|
@@ -22143,7 +22149,7 @@ var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
var PostProcessRenderPipelineManager = (function () {
|
|
|
function PostProcessRenderPipelineManager() {
|
|
|
- this._renderPipelines = [];
|
|
|
+ this._renderPipelines = new Array();
|
|
|
}
|
|
|
PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
|
|
|
this._renderPipelines[renderPipeline._name] = renderPipeline;
|
|
@@ -22156,7 +22162,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.attachCameras(cameras, unique);
|
|
|
+ renderPipeline._attachCameras(cameras, unique);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
|
|
@@ -22166,7 +22172,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.detachCameras(cameras);
|
|
|
+ renderPipeline._detachCameras(cameras);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
|
|
@@ -22176,7 +22182,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.enableEffect(renderEffectName, cameras);
|
|
|
+ renderPipeline._enableEffect(renderEffectName, cameras);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
|
|
@@ -22186,7 +22192,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.disableEffect(renderEffectName, cameras);
|
|
|
+ renderPipeline._disableEffect(renderEffectName, cameras);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.enableDisplayOnlyPassInPipeline = function (renderPipelineName, passName, cameras) {
|
|
@@ -22196,7 +22202,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.enableDisplayOnlyPass(passName, cameras);
|
|
|
+ renderPipeline._enableDisplayOnlyPass(passName, cameras);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.disableDisplayOnlyPassInPipeline = function (renderPipelineName, cameras) {
|
|
@@ -22206,7 +22212,7 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- renderPipeline.disableDisplayOnlyPass(cameras);
|
|
|
+ renderPipeline._disableDisplayOnlyPass(cameras);
|
|
|
};
|
|
|
|
|
|
PostProcessRenderPipelineManager.prototype.update = function () {
|