|
@@ -30512,6 +30512,7 @@ var BABYLON;
|
|
|
_this["layers"] = [];
|
|
|
_this["lensFlareSystems"] = [];
|
|
|
_this["proceduralTextures"] = [];
|
|
|
+ _this["reflectionProbes"] = [];
|
|
|
return _this;
|
|
|
}
|
|
|
/**
|
|
@@ -30558,6 +30559,9 @@ var BABYLON;
|
|
|
this.textures.forEach(function (o) {
|
|
|
_this.scene.addTexture(o);
|
|
|
});
|
|
|
+ this.reflectionProbes.forEach(function (o) {
|
|
|
+ _this.scene.addReflectionProbe(o);
|
|
|
+ });
|
|
|
for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
|
|
|
var component = _a[_i];
|
|
|
component.addFromContainer(this);
|
|
@@ -30607,6 +30611,9 @@ var BABYLON;
|
|
|
this.textures.forEach(function (o) {
|
|
|
_this.scene.removeTexture(o);
|
|
|
});
|
|
|
+ this.reflectionProbes.forEach(function (o) {
|
|
|
+ _this.scene.removeReflectionProbe(o);
|
|
|
+ });
|
|
|
for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
|
|
|
var component = _a[_i];
|
|
|
component.removeFromContainer(this);
|
|
@@ -30649,6 +30656,9 @@ var BABYLON;
|
|
|
this.textures.forEach(function (o) {
|
|
|
o.dispose();
|
|
|
});
|
|
|
+ this.reflectionProbes.forEach(function (o) {
|
|
|
+ o.dispose();
|
|
|
+ });
|
|
|
for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
|
|
|
var component = _a[_i];
|
|
|
component.dispose();
|
|
@@ -32722,7 +32732,7 @@ var BABYLON;
|
|
|
}
|
|
|
return parsedCustomTexture;
|
|
|
}
|
|
|
- if (parsedTexture.isCube) {
|
|
|
+ if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
|
|
|
return BABYLON.CubeTexture.Parse(parsedTexture, scene, rootUrl);
|
|
|
}
|
|
|
if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
|
|
@@ -32740,8 +32750,22 @@ var BABYLON;
|
|
|
return mirrorTexture;
|
|
|
}
|
|
|
else if (parsedTexture.isRenderTarget) {
|
|
|
- var renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
|
|
|
- renderTargetTexture._waitingRenderList = parsedTexture.renderList;
|
|
|
+ var renderTargetTexture = null;
|
|
|
+ if (parsedTexture.isCube) {
|
|
|
+ // Search for an existing reflection probe (which contains a cube render target texture)
|
|
|
+ if (scene.reflectionProbes) {
|
|
|
+ for (var index = 0; index < scene.reflectionProbes.length; index++) {
|
|
|
+ var probe = scene.reflectionProbes[index];
|
|
|
+ if (probe.name === parsedTexture.name) {
|
|
|
+ return probe.cubeTexture;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
|
|
|
+ renderTargetTexture._waitingRenderList = parsedTexture.renderList;
|
|
|
+ }
|
|
|
return renderTargetTexture;
|
|
|
}
|
|
|
else {
|
|
@@ -32762,12 +32786,12 @@ var BABYLON;
|
|
|
// Update Sampling Mode
|
|
|
if (parsedTexture.samplingMode) {
|
|
|
var sampling = parsedTexture.samplingMode;
|
|
|
- if (texture._samplingMode !== sampling) {
|
|
|
+ if (texture && texture._samplingMode !== sampling) {
|
|
|
texture.updateSamplingMode(sampling);
|
|
|
}
|
|
|
}
|
|
|
// Animations
|
|
|
- if (parsedTexture.animations) {
|
|
|
+ if (texture && parsedTexture.animations) {
|
|
|
for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
|
|
|
var parsedAnimation = parsedTexture.animations[animationIndex];
|
|
|
texture.animations.push(BABYLON.Animation.Parse(parsedAnimation));
|
|
@@ -79177,6 +79201,18 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // Reflection probes
|
|
|
+ if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
|
|
|
+ for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
|
|
|
+ var parsedReflectionProbe = parsedData.reflectionProbes[index];
|
|
|
+ var reflectionProbe = BABYLON.ReflectionProbe.Parse(parsedReflectionProbe, scene, rootUrl);
|
|
|
+ if (reflectionProbe) {
|
|
|
+ container.reflectionProbes.push(reflectionProbe);
|
|
|
+ log += (index === 0 ? "\n\tReflection Probes:" : "");
|
|
|
+ log += "\n\t\t" + reflectionProbe.toString(fullDetails);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// Animations
|
|
|
if (parsedData.animations !== undefined && parsedData.animations !== null) {
|
|
|
for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
|
|
@@ -115338,6 +115374,14 @@ var BABYLON;
|
|
|
}
|
|
|
// Animations
|
|
|
BABYLON.Animation.AppendSerializedAnimations(scene, serializationObject);
|
|
|
+ // Reflection probes
|
|
|
+ if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
|
|
|
+ serializationObject.reflectionProbes = [];
|
|
|
+ for (index = 0; index < scene.reflectionProbes.length; index++) {
|
|
|
+ var reflectionProbe = scene.reflectionProbes[index];
|
|
|
+ serializationObject.reflectionProbes.push(reflectionProbe.serialize());
|
|
|
+ }
|
|
|
+ }
|
|
|
// Materials
|
|
|
serializationObject.materials = [];
|
|
|
serializationObject.multiMaterials = [];
|
|
@@ -115459,8 +115503,25 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.sceneSerializer.js.map
|
|
|
|
|
|
+
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ BABYLON.AbstractScene.prototype.removeReflectionProbe = function (toRemove) {
|
|
|
+ if (!this.reflectionProbes) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ var index = this.reflectionProbes.indexOf(toRemove);
|
|
|
+ if (index !== -1) {
|
|
|
+ this.reflectionProbes.splice(index, 1);
|
|
|
+ }
|
|
|
+ return index;
|
|
|
+ };
|
|
|
+ BABYLON.AbstractScene.prototype.addReflectionProbe = function (newReflectionProbe) {
|
|
|
+ if (!this.reflectionProbes) {
|
|
|
+ this.reflectionProbes = [];
|
|
|
+ }
|
|
|
+ this.reflectionProbes.push(newReflectionProbe);
|
|
|
+ };
|
|
|
/**
|
|
|
* Class used to generate realtime reflection / refraction cube textures
|
|
|
* @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
|
|
@@ -115520,16 +115581,16 @@ var BABYLON;
|
|
|
}
|
|
|
_this.position.addToRef(_this._add, _this._target);
|
|
|
BABYLON.Matrix.LookAtLHToRef(_this.position, _this._target, BABYLON.Vector3.Up(), _this._viewMatrix);
|
|
|
- scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
|
|
|
+ if (scene.activeCamera) {
|
|
|
+ _this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
|
|
|
+ scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
|
|
|
+ }
|
|
|
scene._forcedViewPosition = _this.position;
|
|
|
});
|
|
|
this._renderTargetTexture.onAfterUnbindObservable.add(function () {
|
|
|
scene._forcedViewPosition = null;
|
|
|
scene.updateTransformMatrix(true);
|
|
|
});
|
|
|
- if (scene.activeCamera) {
|
|
|
- this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
|
|
|
- }
|
|
|
}
|
|
|
Object.defineProperty(ReflectionProbe.prototype, "samples", {
|
|
|
/** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
|
|
@@ -115605,6 +115666,68 @@ var BABYLON;
|
|
|
this._renderTargetTexture = null;
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Converts the reflection probe information to a readable string for debug purpose.
|
|
|
+ * @param fullDetails Supports for multiple levels of logging within scene loading
|
|
|
+ * @returns the human readable reflection probe info
|
|
|
+ */
|
|
|
+ ReflectionProbe.prototype.toString = function (fullDetails) {
|
|
|
+ var ret = "Name: " + this.name;
|
|
|
+ if (fullDetails) {
|
|
|
+ ret += ", position: " + this.position.toString();
|
|
|
+ if (this._attachedMesh) {
|
|
|
+ ret += ", attached mesh: " + this._attachedMesh.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Get the class name of the relfection probe.
|
|
|
+ * @returns "ReflectionProbe"
|
|
|
+ */
|
|
|
+ ReflectionProbe.prototype.getClassName = function () {
|
|
|
+ return "ReflectionProbe";
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
|
|
|
+ * @returns The JSON representation of the texture
|
|
|
+ */
|
|
|
+ ReflectionProbe.prototype.serialize = function () {
|
|
|
+ var serializationObject = BABYLON.SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
|
|
|
+ serializationObject.isReflectionProbe = true;
|
|
|
+ return serializationObject;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
|
|
|
+ * @param parsedReflectionProbe Define the JSON representation of the reflection probe
|
|
|
+ * @param scene Define the scene the parsed reflection probe should be instantiated in
|
|
|
+ * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
|
|
|
+ * @returns The parsed reflection probe if successful
|
|
|
+ */
|
|
|
+ ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
|
|
|
+ var reflectionProbe = null;
|
|
|
+ if (scene.reflectionProbes) {
|
|
|
+ for (var index = 0; index < scene.reflectionProbes.length; index++) {
|
|
|
+ var rp = scene.reflectionProbes[index];
|
|
|
+ if (rp.name === parsedReflectionProbe.name) {
|
|
|
+ reflectionProbe = rp;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reflectionProbe = BABYLON.SerializationHelper.Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
|
|
|
+ reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
|
|
|
+ if (parsedReflectionProbe._attachedMesh) {
|
|
|
+ reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
|
|
|
+ }
|
|
|
+ return reflectionProbe;
|
|
|
+ };
|
|
|
+ __decorate([
|
|
|
+ BABYLON.serializeAsMeshReference()
|
|
|
+ ], ReflectionProbe.prototype, "_attachedMesh", void 0);
|
|
|
+ __decorate([
|
|
|
+ BABYLON.serializeAsVector3()
|
|
|
+ ], ReflectionProbe.prototype, "position", void 0);
|
|
|
return ReflectionProbe;
|
|
|
}());
|
|
|
BABYLON.ReflectionProbe = ReflectionProbe;
|