|
@@ -18395,6 +18395,9 @@ var BABYLON;
|
|
|
// This matrix is used as a value to reset the bounding box.
|
|
|
var _identityMatrix = BABYLON.Matrix.Identity();
|
|
|
var _tempRadiusVector = new BABYLON.Vector3(0, 0, 0);
|
|
|
+ /**
|
|
|
+ * Class used to store bounding sphere information
|
|
|
+ */
|
|
|
var BoundingSphere = /** @class */ (function () {
|
|
|
/**
|
|
|
* Creates a new bounding sphere
|
|
@@ -18440,6 +18443,11 @@ var BABYLON;
|
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, _tempRadiusVector);
|
|
|
this.radiusWorld = Math.max(Math.abs(_tempRadiusVector.x), Math.abs(_tempRadiusVector.y), Math.abs(_tempRadiusVector.z)) * this.radius;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Tests if the bounding sphere is intersecting the frustum planes
|
|
|
+ * @param frustumPlanes defines the frustum planes to test
|
|
|
+ * @returns true if there is an intersection
|
|
|
+ */
|
|
|
BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
|
|
|
for (var i = 0; i < 6; i++) {
|
|
|
if (frustumPlanes[i].dotCoordinate(this.centerWorld) <= -this.radiusWorld)
|
|
@@ -18447,6 +18455,11 @@ var BABYLON;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Tests if a point is inside the bounding sphere
|
|
|
+ * @param point defines the point to test
|
|
|
+ * @returns true if the point is inside the bounding sphere
|
|
|
+ */
|
|
|
BoundingSphere.prototype.intersectsPoint = function (point) {
|
|
|
var x = this.centerWorld.x - point.x;
|
|
|
var y = this.centerWorld.y - point.y;
|
|
@@ -18457,6 +18470,12 @@ var BABYLON;
|
|
|
return true;
|
|
|
};
|
|
|
// Statics
|
|
|
+ /**
|
|
|
+ * Checks if two sphere intersct
|
|
|
+ * @param sphere0 sphere 0
|
|
|
+ * @param sphere1 sphere 1
|
|
|
+ * @returns true if the speres intersect
|
|
|
+ */
|
|
|
BoundingSphere.Intersects = function (sphere0, sphere1) {
|
|
|
var x = sphere0.centerWorld.x - sphere1.centerWorld.x;
|
|
|
var y = sphere0.centerWorld.y - sphere1.centerWorld.y;
|
|
@@ -18740,8 +18759,24 @@ var BABYLON;
|
|
|
var result1 = computeBoxExtents(axis, box1);
|
|
|
return extentsOverlap(result0.min, result0.max, result1.min, result1.max);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Info for a bounding data of a mesh
|
|
|
+ */
|
|
|
var BoundingInfo = /** @class */ (function () {
|
|
|
- function BoundingInfo(minimum, maximum) {
|
|
|
+ /**
|
|
|
+ * Constructs bounding info
|
|
|
+ * @param minimum min vector of the bounding box/sphere
|
|
|
+ * @param maximum max vector of the bounding box/sphere
|
|
|
+ */
|
|
|
+ function BoundingInfo(
|
|
|
+ /**
|
|
|
+ * min vector of the bounding box/sphere
|
|
|
+ */
|
|
|
+ minimum,
|
|
|
+ /**
|
|
|
+ * max vector of the bounding box/sphere
|
|
|
+ */
|
|
|
+ maximum) {
|
|
|
this.minimum = minimum;
|
|
|
this.maximum = maximum;
|
|
|
this._isLocked = false;
|
|
@@ -18749,6 +18784,9 @@ var BABYLON;
|
|
|
this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
|
|
|
}
|
|
|
Object.defineProperty(BoundingInfo.prototype, "isLocked", {
|
|
|
+ /**
|
|
|
+ * If the info is locked and won't be updated to avoid perf overhead
|
|
|
+ */
|
|
|
get: function () {
|
|
|
return this._isLocked;
|
|
|
},
|
|
@@ -18759,6 +18797,10 @@ var BABYLON;
|
|
|
configurable: true
|
|
|
});
|
|
|
// Methods
|
|
|
+ /**
|
|
|
+ * Updates the boudning sphere and box
|
|
|
+ * @param world world matrix to be used to update
|
|
|
+ */
|
|
|
BoundingInfo.prototype.update = function (world) {
|
|
|
if (this._isLocked) {
|
|
|
return;
|
|
@@ -18770,6 +18812,7 @@ var BABYLON;
|
|
|
* Recreate the bounding info to be centered around a specific point given a specific extend.
|
|
|
* @param center New center of the bounding info
|
|
|
* @param extend New extend of the bounding info
|
|
|
+ * @returns the current bounding info
|
|
|
*/
|
|
|
BoundingInfo.prototype.centerOn = function (center, extend) {
|
|
|
this.minimum = center.subtract(extend);
|
|
@@ -18816,6 +18859,12 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Checks if a cullable object (mesh...) is in the camera frustum
|
|
|
+ * Unlike isInFrustum this cheks the full bounding box
|
|
|
+ * @param frustumPlanes Camera near/planes
|
|
|
+ * @returns true if the object is in frustum otherwise false
|
|
|
+ */
|
|
|
BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
|
|
|
return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
|
|
|
};
|
|
@@ -18823,6 +18872,12 @@ var BABYLON;
|
|
|
BoundingInfo.prototype._checkCollision = function (collider) {
|
|
|
return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Checks if a point is inside the bounding box and bounding sphere or the mesh
|
|
|
+ * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
|
|
|
+ * @param point the point to check intersection with
|
|
|
+ * @returns if the point intersects
|
|
|
+ */
|
|
|
BoundingInfo.prototype.intersectsPoint = function (point) {
|
|
|
if (!this.boundingSphere.centerWorld) {
|
|
|
return false;
|
|
@@ -18835,6 +18890,13 @@ var BABYLON;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
|
|
|
+ * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
|
|
|
+ * @param boundingInfo the bounding info to check intersection with
|
|
|
+ * @param precise if the intersection should be done using OBB
|
|
|
+ * @returns if the bounding info intersects
|
|
|
+ */
|
|
|
BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
|
|
|
if (!this.boundingSphere.centerWorld || !boundingInfo.boundingSphere.centerWorld) {
|
|
|
return false;
|
|
@@ -86583,7 +86645,9 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
- // Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
|
|
|
+ /**
|
|
|
+ * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
|
|
|
+ */
|
|
|
var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
|
|
|
__extends(VolumetricLightScatteringPostProcess, _super);
|
|
|
/**
|
|
@@ -86660,6 +86724,10 @@ var BABYLON;
|
|
|
return _this;
|
|
|
}
|
|
|
Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
|
|
|
+ */
|
|
|
get: function () {
|
|
|
BABYLON.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
|
|
|
return false;
|
|
@@ -86670,6 +86738,10 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Returns the string "VolumetricLightScatteringPostProcess"
|
|
|
+ * @returns "VolumetricLightScatteringPostProcess"
|
|
|
+ */
|
|
|
VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
|
|
|
return "VolumetricLightScatteringPostProcess";
|
|
|
};
|
|
@@ -86724,7 +86796,7 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Sets the new light position for light scattering effect
|
|
|
- * @param {BABYLON.Vector3} The new custom light position
|
|
|
+ * @param position The new custom light position
|
|
|
*/
|
|
|
VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
|
|
|
this.customMeshPosition = position;
|
|
@@ -86915,8 +86987,8 @@ var BABYLON;
|
|
|
// Static methods
|
|
|
/**
|
|
|
* Creates a default mesh for the Volumeric Light Scattering post-process
|
|
|
- * @param {string} The mesh name
|
|
|
- * @param {BABYLON.Scene} The scene where to create the mesh
|
|
|
+ * @param name The mesh name
|
|
|
+ * @param scene The scene where to create the mesh
|
|
|
* @return {BABYLON.Mesh} the default mesh
|
|
|
*/
|
|
|
VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
|
|
@@ -90627,46 +90699,89 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
- // Unique ID when we import meshes from Babylon to CSG
|
|
|
+ /**
|
|
|
+ * Unique ID when we import meshes from Babylon to CSG
|
|
|
+ */
|
|
|
var currentCSGMeshId = 0;
|
|
|
- // # class Vertex
|
|
|
- // Represents a vertex of a polygon. Use your own vertex class instead of this
|
|
|
- // one to provide additional features like texture coordinates and vertex
|
|
|
- // colors. Custom vertex classes need to provide a `pos` property and `clone()`,
|
|
|
- // `flip()`, and `interpolate()` methods that behave analogous to the ones
|
|
|
- // defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
|
|
|
- // functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
|
|
|
- // is not used anywhere else.
|
|
|
- // Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
|
|
|
+ /**
|
|
|
+ * Represents a vertex of a polygon. Use your own vertex class instead of this
|
|
|
+ * one to provide additional features like texture coordinates and vertex
|
|
|
+ * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
|
|
|
+ * `flip()`, and `interpolate()` methods that behave analogous to the ones
|
|
|
+ * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
|
|
|
+ * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
|
|
|
+ * is not used anywhere else.
|
|
|
+ * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
|
|
|
+ */
|
|
|
var Vertex = /** @class */ (function () {
|
|
|
- function Vertex(pos, normal, uv) {
|
|
|
+ /**
|
|
|
+ * Initializes the vertex
|
|
|
+ * @param pos The position of the vertex
|
|
|
+ * @param normal The normal of the vertex
|
|
|
+ * @param uv The texture coordinate of the vertex
|
|
|
+ */
|
|
|
+ function Vertex(
|
|
|
+ /**
|
|
|
+ * The position of the vertex
|
|
|
+ */
|
|
|
+ pos,
|
|
|
+ /**
|
|
|
+ * The normal of the vertex
|
|
|
+ */
|
|
|
+ normal,
|
|
|
+ /**
|
|
|
+ * The texture coordinate of the vertex
|
|
|
+ */
|
|
|
+ uv) {
|
|
|
this.pos = pos;
|
|
|
this.normal = normal;
|
|
|
this.uv = uv;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Make a clone, or deep copy, of the vertex
|
|
|
+ * @returns A new Vertex
|
|
|
+ */
|
|
|
Vertex.prototype.clone = function () {
|
|
|
return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
|
|
|
};
|
|
|
- // Invert all orientation-specific data (e.g. vertex normal). Called when the
|
|
|
- // orientation of a polygon is flipped.
|
|
|
+ /**
|
|
|
+ * Invert all orientation-specific data (e.g. vertex normal). Called when the
|
|
|
+ * orientation of a polygon is flipped.
|
|
|
+ */
|
|
|
Vertex.prototype.flip = function () {
|
|
|
this.normal = this.normal.scale(-1);
|
|
|
};
|
|
|
- // Create a new vertex between this vertex and `other` by linearly
|
|
|
- // interpolating all properties using a parameter of `t`. Subclasses should
|
|
|
- // override this to interpolate additional properties.
|
|
|
+ /**
|
|
|
+ * Create a new vertex between this vertex and `other` by linearly
|
|
|
+ * interpolating all properties using a parameter of `t`. Subclasses should
|
|
|
+ * override this to interpolate additional properties.
|
|
|
+ * @param other the vertex to interpolate against
|
|
|
+ * @param t The factor used to linearly interpolate between the vertices
|
|
|
+ */
|
|
|
Vertex.prototype.interpolate = function (other, t) {
|
|
|
return new Vertex(BABYLON.Vector3.Lerp(this.pos, other.pos, t), BABYLON.Vector3.Lerp(this.normal, other.normal, t), BABYLON.Vector2.Lerp(this.uv, other.uv, t));
|
|
|
};
|
|
|
return Vertex;
|
|
|
}());
|
|
|
- // # class Plane
|
|
|
- // Represents a plane in 3D space.
|
|
|
+ /**
|
|
|
+ * Represents a plane in 3D space.
|
|
|
+ */
|
|
|
var Plane = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Initializes the plane
|
|
|
+ * @param normal The normal for the plane
|
|
|
+ * @param w
|
|
|
+ */
|
|
|
function Plane(normal, w) {
|
|
|
this.normal = normal;
|
|
|
this.w = w;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Construct a plane from three points
|
|
|
+ * @param a Point a
|
|
|
+ * @param b Point b
|
|
|
+ * @param c Point c
|
|
|
+ */
|
|
|
Plane.FromPoints = function (a, b, c) {
|
|
|
var v0 = c.subtract(a);
|
|
|
var v1 = b.subtract(a);
|
|
@@ -90676,18 +90791,32 @@ var BABYLON;
|
|
|
var n = BABYLON.Vector3.Normalize(BABYLON.Vector3.Cross(v0, v1));
|
|
|
return new Plane(n, BABYLON.Vector3.Dot(n, a));
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Clone, or make a deep copy of the plane
|
|
|
+ * @returns a new Plane
|
|
|
+ */
|
|
|
Plane.prototype.clone = function () {
|
|
|
return new Plane(this.normal.clone(), this.w);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Flip the face of the plane
|
|
|
+ */
|
|
|
Plane.prototype.flip = function () {
|
|
|
this.normal.scaleInPlace(-1);
|
|
|
this.w = -this.w;
|
|
|
};
|
|
|
- // Split `polygon` by this plane if needed, then put the polygon or polygon
|
|
|
- // fragments in the appropriate lists. Coplanar polygons go into either
|
|
|
- // `coplanarFront` or `coplanarBack` depending on their orientation with
|
|
|
- // respect to this plane. Polygons in front or in back of this plane go into
|
|
|
- // either `front` or `back`.
|
|
|
+ /**
|
|
|
+ * Split `polygon` by this plane if needed, then put the polygon or polygon
|
|
|
+ * fragments in the appropriate lists. Coplanar polygons go into either
|
|
|
+ `* coplanarFront` or `coplanarBack` depending on their orientation with
|
|
|
+ * respect to this plane. Polygons in front or in back of this plane go into
|
|
|
+ * either `front` or `back`
|
|
|
+ * @param polygon The polygon to be split
|
|
|
+ * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
|
|
|
+ * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
|
|
|
+ * @param front Will contain the polygons in front of the plane
|
|
|
+ * @param back Will contain the polygons begind the plane
|
|
|
+ */
|
|
|
Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
|
|
|
var COPLANAR = 0;
|
|
|
var FRONT = 1;
|
|
@@ -90705,7 +90834,7 @@ var BABYLON;
|
|
|
polygonType |= type;
|
|
|
types.push(type);
|
|
|
}
|
|
|
- // Put the polygon in the correct list, splitting it when necessary.
|
|
|
+ // Put the polygon in the correct list, splitting it when necessary
|
|
|
switch (polygonType) {
|
|
|
case COPLANAR:
|
|
|
(BABYLON.Vector3.Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
|
|
@@ -90747,41 +90876,60 @@ var BABYLON;
|
|
|
break;
|
|
|
}
|
|
|
};
|
|
|
- // `BABYLON.CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
|
|
|
- // point is on the plane.
|
|
|
+ /**
|
|
|
+ * `BABYLON.CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
|
|
|
+ * point is on the plane
|
|
|
+ */
|
|
|
Plane.EPSILON = 1e-5;
|
|
|
return Plane;
|
|
|
}());
|
|
|
- // # class Polygon
|
|
|
- // Represents a convex polygon. The vertices used to initialize a polygon must
|
|
|
- // be coplanar and form a convex loop.
|
|
|
- //
|
|
|
- // Each convex polygon has a `shared` property, which is shared between all
|
|
|
- // polygons that are clones of each other or were split from the same polygon.
|
|
|
- // This can be used to define per-polygon properties (such as surface color).
|
|
|
+ /**
|
|
|
+ * Represents a convex polygon. The vertices used to initialize a polygon must
|
|
|
+ * be coplanar and form a convex loop.
|
|
|
+ *
|
|
|
+ * Each convex polygon has a `shared` property, which is shared between all
|
|
|
+ * polygons that are clones of each other or were split from the same polygon.
|
|
|
+ * This can be used to define per-polygon properties (such as surface color)
|
|
|
+ */
|
|
|
var Polygon = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Initializes the polygon
|
|
|
+ * @param vertices The vertices of the polygon
|
|
|
+ * @param shared The properties shared across all polygons
|
|
|
+ */
|
|
|
function Polygon(vertices, shared) {
|
|
|
this.vertices = vertices;
|
|
|
this.shared = shared;
|
|
|
this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Clones, or makes a deep copy, or the polygon
|
|
|
+ */
|
|
|
Polygon.prototype.clone = function () {
|
|
|
var vertices = this.vertices.map(function (v) { return v.clone(); });
|
|
|
return new Polygon(vertices, this.shared);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Flips the faces of the polygon
|
|
|
+ */
|
|
|
Polygon.prototype.flip = function () {
|
|
|
this.vertices.reverse().map(function (v) { v.flip(); });
|
|
|
this.plane.flip();
|
|
|
};
|
|
|
return Polygon;
|
|
|
}());
|
|
|
- // # class Node
|
|
|
- // Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
|
|
|
- // by picking a polygon to split along. That polygon (and all other coplanar
|
|
|
- // polygons) are added directly to that node and the other polygons are added to
|
|
|
- // the front and/or back subtrees. This is not a leafy BSP tree since there is
|
|
|
- // no distinction between internal and leaf nodes.
|
|
|
+ /**
|
|
|
+ * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
|
|
|
+ * by picking a polygon to split along. That polygon (and all other coplanar
|
|
|
+ * polygons) are added directly to that node and the other polygons are added to
|
|
|
+ * the front and/or back subtrees. This is not a leafy BSP tree since there is
|
|
|
+ * no distinction between internal and leaf nodes
|
|
|
+ */
|
|
|
var Node = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Initializes the node
|
|
|
+ * @param polygons A collection of polygons held in the node
|
|
|
+ */
|
|
|
function Node(polygons) {
|
|
|
this.plane = null;
|
|
|
this.front = null;
|
|
@@ -90791,6 +90939,10 @@ var BABYLON;
|
|
|
this.build(polygons);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Clones, or makes a deep copy, of the node
|
|
|
+ * @returns The cloned node
|
|
|
+ */
|
|
|
Node.prototype.clone = function () {
|
|
|
var node = new Node();
|
|
|
node.plane = this.plane && this.plane.clone();
|
|
@@ -90799,7 +90951,9 @@ var BABYLON;
|
|
|
node.polygons = this.polygons.map(function (p) { return p.clone(); });
|
|
|
return node;
|
|
|
};
|
|
|
- // Convert solid space to empty space and empty space to solid space.
|
|
|
+ /**
|
|
|
+ * Convert solid space to empty space and empty space to solid space
|
|
|
+ */
|
|
|
Node.prototype.invert = function () {
|
|
|
for (var i = 0; i < this.polygons.length; i++) {
|
|
|
this.polygons[i].flip();
|
|
@@ -90817,8 +90971,12 @@ var BABYLON;
|
|
|
this.front = this.back;
|
|
|
this.back = temp;
|
|
|
};
|
|
|
- // Recursively remove all polygons in `polygons` that are inside this BSP
|
|
|
- // tree.
|
|
|
+ /**
|
|
|
+ * Recursively remove all polygons in `polygons` that are inside this BSP
|
|
|
+ * tree.
|
|
|
+ * @param polygons Polygons to remove from the BSP
|
|
|
+ * @returns Polygons clipped from the BSP
|
|
|
+ */
|
|
|
Node.prototype.clipPolygons = function (polygons) {
|
|
|
if (!this.plane)
|
|
|
return polygons.slice();
|
|
@@ -90837,8 +90995,11 @@ var BABYLON;
|
|
|
}
|
|
|
return front.concat(back);
|
|
|
};
|
|
|
- // Remove all polygons in this BSP tree that are inside the other BSP tree
|
|
|
- // `bsp`.
|
|
|
+ /**
|
|
|
+ * Remove all polygons in this BSP tree that are inside the other BSP tree
|
|
|
+ * `bsp`.
|
|
|
+ * @param bsp BSP containing polygons to remove from this BSP
|
|
|
+ */
|
|
|
Node.prototype.clipTo = function (bsp) {
|
|
|
this.polygons = bsp.clipPolygons(this.polygons);
|
|
|
if (this.front)
|
|
@@ -90846,7 +91007,10 @@ var BABYLON;
|
|
|
if (this.back)
|
|
|
this.back.clipTo(bsp);
|
|
|
};
|
|
|
- // Return a list of all polygons in this BSP tree.
|
|
|
+ /**
|
|
|
+ * Return a list of all polygons in this BSP tree
|
|
|
+ * @returns List of all polygons in this BSP tree
|
|
|
+ */
|
|
|
Node.prototype.allPolygons = function () {
|
|
|
var polygons = this.polygons.slice();
|
|
|
if (this.front)
|
|
@@ -90855,10 +91019,13 @@ var BABYLON;
|
|
|
polygons = polygons.concat(this.back.allPolygons());
|
|
|
return polygons;
|
|
|
};
|
|
|
- // Build a BSP tree out of `polygons`. When called on an existing tree, the
|
|
|
- // new polygons are filtered down to the bottom of the tree and become new
|
|
|
- // nodes there. Each set of polygons is partitioned using the first polygon
|
|
|
- // (no heuristic is used to pick a good split).
|
|
|
+ /**
|
|
|
+ * Build a BSP tree out of `polygons`. When called on an existing tree, the
|
|
|
+ * new polygons are filtered down to the bottom of the tree and become new
|
|
|
+ * nodes there. Each set of polygons is partitioned using the first polygon
|
|
|
+ * (no heuristic is used to pick a good split)
|
|
|
+ * @param polygons Polygons used to construct the BSP tree
|
|
|
+ */
|
|
|
Node.prototype.build = function (polygons) {
|
|
|
if (!polygons.length)
|
|
|
return;
|
|
@@ -90881,11 +91048,18 @@ var BABYLON;
|
|
|
};
|
|
|
return Node;
|
|
|
}());
|
|
|
+ /**
|
|
|
+ * Class for building Constructive Solid Geometry
|
|
|
+ */
|
|
|
var CSG = /** @class */ (function () {
|
|
|
function CSG() {
|
|
|
this.polygons = new Array();
|
|
|
}
|
|
|
- // Convert BABYLON.Mesh to BABYLON.CSG
|
|
|
+ /**
|
|
|
+ * Convert the BABYLON.Mesh to BABYLON.CSG
|
|
|
+ * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
|
|
|
+ * @returns A new BABYLON.CSG from the BABYLON.Mesh
|
|
|
+ */
|
|
|
CSG.FromMesh = function (mesh) {
|
|
|
var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
|
|
|
var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
|
|
@@ -90932,18 +91106,30 @@ var BABYLON;
|
|
|
currentCSGMeshId++;
|
|
|
return csg;
|
|
|
};
|
|
|
- // Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
|
|
|
+ /**
|
|
|
+ * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
|
|
|
+ * @param polygons Polygons used to construct a BABYLON.CSG solid
|
|
|
+ */
|
|
|
CSG.FromPolygons = function (polygons) {
|
|
|
var csg = new CSG();
|
|
|
csg.polygons = polygons;
|
|
|
return csg;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Clones, or makes a deep copy, of the BABYLON.CSG
|
|
|
+ * @returns A new BABYLON.CSG
|
|
|
+ */
|
|
|
CSG.prototype.clone = function () {
|
|
|
var csg = new CSG();
|
|
|
csg.polygons = this.polygons.map(function (p) { return p.clone(); });
|
|
|
csg.copyTransformAttributes(this);
|
|
|
return csg;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Unions this CSG with another CSG
|
|
|
+ * @param csg The CSG to union against this CSG
|
|
|
+ * @returns The unioned CSG
|
|
|
+ */
|
|
|
CSG.prototype.union = function (csg) {
|
|
|
var a = new Node(this.clone().polygons);
|
|
|
var b = new Node(csg.clone().polygons);
|
|
@@ -90955,6 +91141,10 @@ var BABYLON;
|
|
|
a.build(b.allPolygons());
|
|
|
return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Unions this CSG with another CSG in place
|
|
|
+ * @param csg The CSG to union against this CSG
|
|
|
+ */
|
|
|
CSG.prototype.unionInPlace = function (csg) {
|
|
|
var a = new Node(this.polygons);
|
|
|
var b = new Node(csg.polygons);
|
|
@@ -90966,6 +91156,11 @@ var BABYLON;
|
|
|
a.build(b.allPolygons());
|
|
|
this.polygons = a.allPolygons();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Subtracts this CSG with another CSG
|
|
|
+ * @param csg The CSG to subtract against this CSG
|
|
|
+ * @returns A new BABYLON.CSG
|
|
|
+ */
|
|
|
CSG.prototype.subtract = function (csg) {
|
|
|
var a = new Node(this.clone().polygons);
|
|
|
var b = new Node(csg.clone().polygons);
|
|
@@ -90979,6 +91174,10 @@ var BABYLON;
|
|
|
a.invert();
|
|
|
return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Subtracts this CSG with another CSG in place
|
|
|
+ * @param csg The CSG to subtact against this CSG
|
|
|
+ */
|
|
|
CSG.prototype.subtractInPlace = function (csg) {
|
|
|
var a = new Node(this.polygons);
|
|
|
var b = new Node(csg.polygons);
|
|
@@ -90992,6 +91191,11 @@ var BABYLON;
|
|
|
a.invert();
|
|
|
this.polygons = a.allPolygons();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Intersect this CSG with another CSG
|
|
|
+ * @param csg The CSG to intersect against this CSG
|
|
|
+ * @returns A new BABYLON.CSG
|
|
|
+ */
|
|
|
CSG.prototype.intersect = function (csg) {
|
|
|
var a = new Node(this.clone().polygons);
|
|
|
var b = new Node(csg.clone().polygons);
|
|
@@ -91004,6 +91208,10 @@ var BABYLON;
|
|
|
a.invert();
|
|
|
return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Intersects this CSG with another CSG in place
|
|
|
+ * @param csg The CSG to intersect against this CSG
|
|
|
+ */
|
|
|
CSG.prototype.intersectInPlace = function (csg) {
|
|
|
var a = new Node(this.polygons);
|
|
|
var b = new Node(csg.polygons);
|
|
@@ -91016,19 +91224,29 @@ var BABYLON;
|
|
|
a.invert();
|
|
|
this.polygons = a.allPolygons();
|
|
|
};
|
|
|
- // Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
|
|
|
- // not modified.
|
|
|
+ /**
|
|
|
+ * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
|
|
|
+ * not modified.
|
|
|
+ * @returns A new BABYLON.CSG solid with solid and empty space switched
|
|
|
+ */
|
|
|
CSG.prototype.inverse = function () {
|
|
|
var csg = this.clone();
|
|
|
csg.inverseInPlace();
|
|
|
return csg;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Inverses the BABYLON.CSG in place
|
|
|
+ */
|
|
|
CSG.prototype.inverseInPlace = function () {
|
|
|
this.polygons.map(function (p) { p.flip(); });
|
|
|
};
|
|
|
- // This is used to keep meshes transformations so they can be restored
|
|
|
- // when we build back a Babylon Mesh
|
|
|
- // NB : All CSG operations are performed in world coordinates
|
|
|
+ /**
|
|
|
+ * This is used to keep meshes transformations so they can be restored
|
|
|
+ * when we build back a Babylon Mesh
|
|
|
+ * NB : All CSG operations are performed in world coordinates
|
|
|
+ * @param csg The BABYLON.CSG to copy the transform attributes from
|
|
|
+ * @returns This BABYLON.CSG
|
|
|
+ */
|
|
|
CSG.prototype.copyTransformAttributes = function (csg) {
|
|
|
this.matrix = csg.matrix;
|
|
|
this.position = csg.position;
|
|
@@ -91037,8 +91255,14 @@ var BABYLON;
|
|
|
this.rotationQuaternion = csg.rotationQuaternion;
|
|
|
return this;
|
|
|
};
|
|
|
- // Build Raw mesh from CSG
|
|
|
- // Coordinates here are in world space
|
|
|
+ /**
|
|
|
+ * Build Raw mesh from CSG
|
|
|
+ * Coordinates here are in world space
|
|
|
+ * @param name The name of the mesh geometry
|
|
|
+ * @param scene The BABYLON.Scene
|
|
|
+ * @param keepSubMeshes Specifies if the submeshes should be kept
|
|
|
+ * @returns A new BABYLON.Mesh
|
|
|
+ */
|
|
|
CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
|
|
|
var matrix = this.matrix.clone();
|
|
|
matrix.invert();
|
|
@@ -91118,7 +91342,14 @@ var BABYLON;
|
|
|
}
|
|
|
return mesh;
|
|
|
};
|
|
|
- // Build Mesh from CSG taking material and transforms into account
|
|
|
+ /**
|
|
|
+ * Build Mesh from CSG taking material and transforms into account
|
|
|
+ * @param name The name of the BABYLON.Mesh
|
|
|
+ * @param material The material of the BABYLON.Mesh
|
|
|
+ * @param scene The BABYLON.Scene
|
|
|
+ * @param keepSubMeshes Specifies if submeshes should be kept
|
|
|
+ * @returns The new BABYLON.Mesh
|
|
|
+ */
|
|
|
CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
|
|
|
var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
|
|
|
mesh.material = material;
|