|
@@ -1,14 +1,31 @@
|
|
|
module BABYLON {
|
|
|
/**
|
|
|
- * Creates a refraction texture used by refraction channel of the standard material.
|
|
|
- * @param name the texture name
|
|
|
- * @param size size of the underlying texture
|
|
|
- * @param scene root scene
|
|
|
- */
|
|
|
+ * Creates a refraction texture used by refraction channel of the standard material.
|
|
|
+ * It is like a mirror but to see through a material.
|
|
|
+ * @see https://doc.babylonjs.com/how_to/reflect#refraction
|
|
|
+ */
|
|
|
export class RefractionTexture extends RenderTargetTexture {
|
|
|
+ /**
|
|
|
+ * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
|
|
|
+ * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
|
|
|
+ * @see https://doc.babylonjs.com/how_to/reflect#refraction
|
|
|
+ */
|
|
|
public refractionPlane = new Plane(0, 1, 0, 1);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Define how deep under the surface we should see.
|
|
|
+ */
|
|
|
public depth = 2.0;
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a refraction texture used by refraction channel of the standard material.
|
|
|
+ * It is like a mirror but to see through a material.
|
|
|
+ * @see https://doc.babylonjs.com/how_to/reflect#refraction
|
|
|
+ * @param name Define the texture name
|
|
|
+ * @param size Define the size of the underlying texture
|
|
|
+ * @param scene Define the scene the refraction belongs to
|
|
|
+ * @param generateMipMaps Define if we need to generate mips level for the refraction
|
|
|
+ */
|
|
|
constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean) {
|
|
|
super(name, size, scene, generateMipMaps, true);
|
|
|
|
|
@@ -21,6 +38,10 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Clone the refraction texture.
|
|
|
+ * @returns the cloned texture
|
|
|
+ */
|
|
|
public clone(): RefractionTexture {
|
|
|
let scene = this.getScene();
|
|
|
|
|
@@ -45,6 +66,10 @@
|
|
|
return newTexture;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Serialize the texture to a JSON representation you could use in Parse later on
|
|
|
+ * @returns the serialized JSON representation
|
|
|
+ */
|
|
|
public serialize(): any {
|
|
|
if (!this.name) {
|
|
|
return null;
|