|
@@ -22694,6 +22694,18 @@ var Camera = /** @class */ (function (_super) {
|
|
|
throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
|
|
|
};
|
|
|
/**
|
|
|
+ * Gets a ray in the forward direction from the camera.
|
|
|
+ * @param refRay the ray to (re)use when setting the values
|
|
|
+ * @param length Defines the length of the ray to create
|
|
|
+ * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
|
|
|
+ * @param origin Defines the start point of the ray which defaults to the camera position
|
|
|
+ * @returns the forward ray
|
|
|
+ */
|
|
|
+ Camera.prototype.getForwardRayToRef = function (refRay, length, transform, origin) {
|
|
|
+ if (length === void 0) { length = 100; }
|
|
|
+ throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Releases resources associated with this node.
|
|
|
* @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
|
|
|
* @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
|
|
@@ -27983,17 +27995,17 @@ var Ray = /** @class */ (function () {
|
|
|
var x = sphere.center.x - this.origin.x;
|
|
|
var y = sphere.center.y - this.origin.y;
|
|
|
var z = sphere.center.z - this.origin.z;
|
|
|
- var pyth = (x * x) + (y * y) + (z * z);
|
|
|
+ var pyth = x * x + y * y + z * z;
|
|
|
var radius = sphere.radius + intersectionTreshold;
|
|
|
var rr = radius * radius;
|
|
|
if (pyth <= rr) {
|
|
|
return true;
|
|
|
}
|
|
|
- var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
|
|
|
+ var dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;
|
|
|
if (dot < 0.0) {
|
|
|
return false;
|
|
|
}
|
|
|
- var temp = pyth - (dot * dot);
|
|
|
+ var temp = pyth - dot * dot;
|
|
|
return temp <= rr;
|
|
|
};
|
|
|
/**
|
|
@@ -28042,14 +28054,14 @@ var Ray = /** @class */ (function () {
|
|
|
Ray.prototype.intersectsPlane = function (plane) {
|
|
|
var distance;
|
|
|
var result1 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
|
|
|
- if (Math.abs(result1) < 9.99999997475243E-07) {
|
|
|
+ if (Math.abs(result1) < 9.99999997475243e-7) {
|
|
|
return null;
|
|
|
}
|
|
|
else {
|
|
|
var result2 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
|
|
|
distance = (-plane.d - result2) / result1;
|
|
|
if (distance < 0.0) {
|
|
|
- if (distance < -9.99999997475243E-07) {
|
|
|
+ if (distance < -9.99999997475243e-7) {
|
|
|
return null;
|
|
|
}
|
|
|
else {
|
|
@@ -28068,24 +28080,24 @@ var Ray = /** @class */ (function () {
|
|
|
Ray.prototype.intersectsAxis = function (axis, offset) {
|
|
|
if (offset === void 0) { offset = 0; }
|
|
|
switch (axis) {
|
|
|
- case 'y':
|
|
|
+ case "y":
|
|
|
var t = (this.origin.y - offset) / this.direction.y;
|
|
|
if (t > 0) {
|
|
|
return null;
|
|
|
}
|
|
|
- return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + (this.direction.x * -t), offset, this.origin.z + (this.direction.z * -t));
|
|
|
- case 'x':
|
|
|
+ return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);
|
|
|
+ case "x":
|
|
|
var t = (this.origin.x - offset) / this.direction.x;
|
|
|
if (t > 0) {
|
|
|
return null;
|
|
|
}
|
|
|
- return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](offset, this.origin.y + (this.direction.y * -t), this.origin.z + (this.direction.z * -t));
|
|
|
- case 'z':
|
|
|
+ return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);
|
|
|
+ case "z":
|
|
|
var t = (this.origin.z - offset) / this.direction.z;
|
|
|
if (t > 0) {
|
|
|
return null;
|
|
|
}
|
|
|
- return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + (this.direction.x * -t), this.origin.y + (this.direction.y * -t), offset);
|
|
|
+ return new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);
|
|
|
default:
|
|
|
return null;
|
|
|
}
|
|
@@ -28167,27 +28179,32 @@ var Ray = /** @class */ (function () {
|
|
|
var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
|
|
|
var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
|
|
|
// compute the line parameters of the two closest points
|
|
|
- if (D < Ray.smallnum) { // the lines are almost parallel
|
|
|
+ if (D < Ray.smallnum) {
|
|
|
+ // the lines are almost parallel
|
|
|
sN = 0.0; // force using point P0 on segment S1
|
|
|
sD = 1.0; // to prevent possible division by 0.0 later
|
|
|
tN = e;
|
|
|
tD = c;
|
|
|
}
|
|
|
- else { // get the closest points on the infinite lines
|
|
|
- sN = (b * e - c * d);
|
|
|
- tN = (a * e - b * d);
|
|
|
- if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
|
|
|
+ else {
|
|
|
+ // get the closest points on the infinite lines
|
|
|
+ sN = b * e - c * d;
|
|
|
+ tN = a * e - b * d;
|
|
|
+ if (sN < 0.0) {
|
|
|
+ // sc < 0 => the s=0 edge is visible
|
|
|
sN = 0.0;
|
|
|
tN = e;
|
|
|
tD = c;
|
|
|
}
|
|
|
- else if (sN > sD) { // sc > 1 => the s=1 edge is visible
|
|
|
+ else if (sN > sD) {
|
|
|
+ // sc > 1 => the s=1 edge is visible
|
|
|
sN = sD;
|
|
|
tN = e + b;
|
|
|
tD = c;
|
|
|
}
|
|
|
}
|
|
|
- if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
|
|
|
+ if (tN < 0.0) {
|
|
|
+ // tc < 0 => the t=0 edge is visible
|
|
|
tN = 0.0;
|
|
|
// recompute sc for this edge
|
|
|
if (-d < 0.0) {
|
|
@@ -28201,23 +28218,24 @@ var Ray = /** @class */ (function () {
|
|
|
sD = a;
|
|
|
}
|
|
|
}
|
|
|
- else if (tN > tD) { // tc > 1 => the t=1 edge is visible
|
|
|
+ else if (tN > tD) {
|
|
|
+ // tc > 1 => the t=1 edge is visible
|
|
|
tN = tD;
|
|
|
// recompute sc for this edge
|
|
|
- if ((-d + b) < 0.0) {
|
|
|
+ if (-d + b < 0.0) {
|
|
|
sN = 0;
|
|
|
}
|
|
|
- else if ((-d + b) > a) {
|
|
|
+ else if (-d + b > a) {
|
|
|
sN = sD;
|
|
|
}
|
|
|
else {
|
|
|
- sN = (-d + b);
|
|
|
+ sN = -d + b;
|
|
|
sD = a;
|
|
|
}
|
|
|
}
|
|
|
// finally do the division to get sc and tc
|
|
|
- sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
|
|
|
- tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
|
|
|
+ sc = Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD;
|
|
|
+ tc = Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD;
|
|
|
// get the difference of the two closest points
|
|
|
var qtc = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[4];
|
|
|
v.scaleToRef(tc, qtc);
|
|
@@ -28226,7 +28244,7 @@ var Ray = /** @class */ (function () {
|
|
|
qsc.addInPlace(w);
|
|
|
var dP = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[6];
|
|
|
qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
|
|
|
- var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
|
|
|
+ var isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result
|
|
|
if (isIntersected) {
|
|
|
return qsc.length();
|
|
|
}
|
|
@@ -28271,17 +28289,17 @@ var Ray = /** @class */ (function () {
|
|
|
return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
|
|
|
};
|
|
|
/**
|
|
|
- * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
|
|
|
- * transformed to the given world matrix.
|
|
|
- * @param origin The origin point
|
|
|
- * @param end The end point
|
|
|
- * @param world a matrix to transform the ray to. Default is the identity matrix.
|
|
|
- * @returns the new ray
|
|
|
- */
|
|
|
+ * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
|
|
|
+ * transformed to the given world matrix.
|
|
|
+ * @param origin The origin point
|
|
|
+ * @param end The end point
|
|
|
+ * @param world a matrix to transform the ray to. Default is the identity matrix.
|
|
|
+ * @returns the new ray
|
|
|
+ */
|
|
|
Ray.CreateNewFromTo = function (origin, end, world) {
|
|
|
if (world === void 0) { world = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
|
|
|
var direction = end.subtract(origin);
|
|
|
- var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
|
|
|
+ var length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);
|
|
|
direction.normalize();
|
|
|
return Ray.Transform(new Ray(origin, direction, length), world);
|
|
|
};
|
|
@@ -28317,23 +28335,23 @@ var Ray = /** @class */ (function () {
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
|
- * Unproject a ray from screen space to object space
|
|
|
- * @param sourceX defines the screen space x coordinate to use
|
|
|
- * @param sourceY defines the screen space y coordinate to use
|
|
|
- * @param viewportWidth defines the current width of the viewport
|
|
|
- * @param viewportHeight defines the current height of the viewport
|
|
|
- * @param world defines the world matrix to use (can be set to Identity to go to world space)
|
|
|
- * @param view defines the view matrix to use
|
|
|
- * @param projection defines the projection matrix to use
|
|
|
- */
|
|
|
+ * Unproject a ray from screen space to object space
|
|
|
+ * @param sourceX defines the screen space x coordinate to use
|
|
|
+ * @param sourceY defines the screen space y coordinate to use
|
|
|
+ * @param viewportWidth defines the current width of the viewport
|
|
|
+ * @param viewportHeight defines the current height of the viewport
|
|
|
+ * @param world defines the world matrix to use (can be set to Identity to go to world space)
|
|
|
+ * @param view defines the view matrix to use
|
|
|
+ * @param projection defines the projection matrix to use
|
|
|
+ */
|
|
|
Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
|
|
|
var matrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0];
|
|
|
world.multiplyToRef(view, matrix);
|
|
|
matrix.multiplyToRef(projection, matrix);
|
|
|
matrix.invert();
|
|
|
var nearScreenSource = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
|
|
|
- nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
|
|
|
- nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
|
|
|
+ nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;
|
|
|
+ nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);
|
|
|
nearScreenSource.z = -1.0;
|
|
|
var farScreenSource = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
|
|
|
var nearVec3 = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2];
|
|
@@ -28526,16 +28544,24 @@ _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = functi
|
|
|
};
|
|
|
_Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
|
|
|
if (length === void 0) { length = 100; }
|
|
|
+ return this.getForwardRayToRef(new Ray(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), length), length, transform, origin);
|
|
|
+};
|
|
|
+_Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRayToRef = function (refRay, length, transform, origin) {
|
|
|
+ if (length === void 0) { length = 100; }
|
|
|
if (!transform) {
|
|
|
transform = this.getWorldMatrix();
|
|
|
}
|
|
|
+ refRay.length = length;
|
|
|
if (!origin) {
|
|
|
- origin = this.position;
|
|
|
+ refRay.origin.copyFrom(this.position);
|
|
|
}
|
|
|
- var forward = this._scene.useRightHandedSystem ? new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
|
|
|
- var forwardWorld = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
|
|
|
- var direction = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
|
|
|
- return new Ray(origin, direction, length);
|
|
|
+ else {
|
|
|
+ refRay.origin.copyFrom(origin);
|
|
|
+ }
|
|
|
+ _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1);
|
|
|
+ _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[2], transform, _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[3]);
|
|
|
+ _Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[3], refRay.direction);
|
|
|
+ return refRay;
|
|
|
};
|
|
|
|
|
|
|
|
@@ -60945,44 +60971,48 @@ var SceneLoader = /** @class */ (function () {
|
|
|
enumerable: false,
|
|
|
configurable: true
|
|
|
});
|
|
|
- SceneLoader._getDefaultPlugin = function () {
|
|
|
+ /**
|
|
|
+ * Gets the default plugin (used to load Babylon files)
|
|
|
+ * @returns the .babylon plugin
|
|
|
+ */
|
|
|
+ SceneLoader.GetDefaultPlugin = function () {
|
|
|
return SceneLoader._registeredPlugins[".babylon"];
|
|
|
};
|
|
|
- SceneLoader._getPluginForExtension = function (extension) {
|
|
|
+ SceneLoader._GetPluginForExtension = function (extension) {
|
|
|
var registeredPlugin = SceneLoader._registeredPlugins[extension];
|
|
|
if (registeredPlugin) {
|
|
|
return registeredPlugin;
|
|
|
}
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("Unable to find a plugin to load " + extension + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type");
|
|
|
- return SceneLoader._getDefaultPlugin();
|
|
|
+ return SceneLoader.GetDefaultPlugin();
|
|
|
};
|
|
|
- SceneLoader._getPluginForDirectLoad = function (data) {
|
|
|
+ SceneLoader._GetPluginForDirectLoad = function (data) {
|
|
|
for (var extension in SceneLoader._registeredPlugins) {
|
|
|
var plugin = SceneLoader._registeredPlugins[extension].plugin;
|
|
|
if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
|
|
|
return SceneLoader._registeredPlugins[extension];
|
|
|
}
|
|
|
}
|
|
|
- return SceneLoader._getDefaultPlugin();
|
|
|
+ return SceneLoader.GetDefaultPlugin();
|
|
|
};
|
|
|
- SceneLoader._getPluginForFilename = function (sceneFilename) {
|
|
|
+ SceneLoader._GetPluginForFilename = function (sceneFilename) {
|
|
|
var queryStringPosition = sceneFilename.indexOf("?");
|
|
|
if (queryStringPosition !== -1) {
|
|
|
sceneFilename = sceneFilename.substring(0, queryStringPosition);
|
|
|
}
|
|
|
var dotPosition = sceneFilename.lastIndexOf(".");
|
|
|
var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
|
|
|
- return SceneLoader._getPluginForExtension(extension);
|
|
|
+ return SceneLoader._GetPluginForExtension(extension);
|
|
|
};
|
|
|
- SceneLoader._getDirectLoad = function (sceneFilename) {
|
|
|
+ SceneLoader._GetDirectLoad = function (sceneFilename) {
|
|
|
if (sceneFilename.substr(0, 5) === "data:") {
|
|
|
return sceneFilename.substr(5);
|
|
|
}
|
|
|
return null;
|
|
|
};
|
|
|
- SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
|
|
|
- var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
|
|
|
- var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
|
|
|
+ SceneLoader._LoadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
|
|
|
+ var directLoad = SceneLoader._GetDirectLoad(fileInfo.name);
|
|
|
+ var registeredPlugin = pluginExtension ? SceneLoader._GetPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._GetPluginForDirectLoad(fileInfo.name) : SceneLoader._GetPluginForFilename(fileInfo.name));
|
|
|
var plugin;
|
|
|
if (registeredPlugin.plugin.createPlugin !== undefined) {
|
|
|
plugin = registeredPlugin.plugin.createPlugin();
|
|
@@ -61088,7 +61118,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
}
|
|
|
return plugin;
|
|
|
};
|
|
|
- SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
|
|
|
+ SceneLoader._GetFileInfo = function (rootUrl, sceneFilename) {
|
|
|
var url;
|
|
|
var name;
|
|
|
var file = null;
|
|
@@ -61126,7 +61156,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
* @returns a plugin or null if none works
|
|
|
*/
|
|
|
SceneLoader.GetPluginForExtension = function (extension) {
|
|
|
- return SceneLoader._getPluginForExtension(extension).plugin;
|
|
|
+ return SceneLoader._GetPluginForExtension(extension).plugin;
|
|
|
};
|
|
|
/**
|
|
|
* Gets a boolean indicating that the given extension can be loaded
|
|
@@ -61181,7 +61211,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
|
|
|
return null;
|
|
|
}
|
|
|
- var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ var fileInfo = SceneLoader._GetFileInfo(rootUrl, sceneFilename);
|
|
|
if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
@@ -61221,7 +61251,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
|
|
|
+ return SceneLoader._LoadData(fileInfo, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.rewriteRootURL) {
|
|
|
fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
|
|
|
}
|
|
@@ -61344,7 +61374,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
|
|
|
return null;
|
|
|
}
|
|
|
- var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ var fileInfo = SceneLoader._GetFileInfo(rootUrl, sceneFilename);
|
|
|
if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
@@ -61391,7 +61421,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
|
|
|
+ return SceneLoader._LoadData(fileInfo, scene, function (plugin, data) {
|
|
|
if (plugin.load) {
|
|
|
var syncedPlugin = plugin;
|
|
|
if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
|
|
@@ -61455,7 +61485,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
|
|
|
return null;
|
|
|
}
|
|
|
- var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
|
|
|
+ var fileInfo = SceneLoader._GetFileInfo(rootUrl, sceneFilename);
|
|
|
if (!fileInfo) {
|
|
|
return null;
|
|
|
}
|
|
@@ -61497,7 +61527,7 @@ var SceneLoader = /** @class */ (function () {
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
|
|
|
+ return SceneLoader._LoadData(fileInfo, scene, function (plugin, data) {
|
|
|
if (plugin.loadAssetContainer) {
|
|
|
var syncedPlugin = plugin;
|
|
|
var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
|
|
@@ -103914,6 +103944,17 @@ var Color3 = /** @class */ (function () {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Update the current color with values stored in an array from the starting index of the given array
|
|
|
+ * @param array defines the source array
|
|
|
+ * @param offset defines an offset in the source array
|
|
|
+ * @returns the current Color3 object
|
|
|
+ */
|
|
|
+ Color3.prototype.fromArray = function (array, offset) {
|
|
|
+ if (offset === void 0) { offset = 0; }
|
|
|
+ Color3.FromArrayToRef(array, offset, this);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Returns a new Color4 object from the current Color3 and the given alpha
|
|
|
* @param alpha defines the alpha component on the new Color4 object (default is 1)
|
|
|
* @returns a new Color4 object
|
|
@@ -104265,6 +104306,18 @@ var Color3 = /** @class */ (function () {
|
|
|
return new Color3(array[offset], array[offset + 1], array[offset + 2]);
|
|
|
};
|
|
|
/**
|
|
|
+ * Creates a new Color3 from the starting index element of the given array
|
|
|
+ * @param array defines the source array to read from
|
|
|
+ * @param offset defines the offset in the source array
|
|
|
+ * @param result defines the target Color3 object
|
|
|
+ */
|
|
|
+ Color3.FromArrayToRef = function (array, offset, result) {
|
|
|
+ if (offset === void 0) { offset = 0; }
|
|
|
+ result.r = array[offset];
|
|
|
+ result.g = array[offset + 1];
|
|
|
+ result.b = array[offset + 2];
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Creates a new Color3 from integer values (< 256)
|
|
|
* @param r defines the red component to read from (value between 0 and 255)
|
|
|
* @param g defines the green component to read from (value between 0 and 255)
|
|
@@ -104442,6 +104495,17 @@ var Color4 = /** @class */ (function () {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Update the current color with values stored in an array from the starting index of the given array
|
|
|
+ * @param array defines the source array
|
|
|
+ * @param offset defines an offset in the source array
|
|
|
+ * @returns the current Color4 object
|
|
|
+ */
|
|
|
+ Color4.prototype.fromArray = function (array, offset) {
|
|
|
+ if (offset === void 0) { offset = 0; }
|
|
|
+ Color4.FromArrayToRef(array, offset, this);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Determines equality between Color4 objects
|
|
|
* @param otherColor defines the second operand
|
|
|
* @returns true if the rgba values are equal to the given ones
|
|
@@ -104739,6 +104803,19 @@ var Color4 = /** @class */ (function () {
|
|
|
return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
|
|
|
};
|
|
|
/**
|
|
|
+ * Creates a new Color4 from the starting index element of the given array
|
|
|
+ * @param array defines the source array to read from
|
|
|
+ * @param offset defines the offset in the source array
|
|
|
+ * @param result defines the target Color4 object
|
|
|
+ */
|
|
|
+ Color4.FromArrayToRef = function (array, offset, result) {
|
|
|
+ if (offset === void 0) { offset = 0; }
|
|
|
+ result.r = array[offset];
|
|
|
+ result.g = array[offset + 1];
|
|
|
+ result.b = array[offset + 2];
|
|
|
+ result.a = array[offset + 3];
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Creates a new Color3 from integer values (< 256)
|
|
|
* @param r defines the red component to read from (value between 0 and 255)
|
|
|
* @param g defines the green component to read from (value between 0 and 255)
|
|
@@ -106781,6 +106858,17 @@ var Vector2 = /** @class */ (function () {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Update the current vector from an array
|
|
|
+ * @param array defines the destination array
|
|
|
+ * @param index defines the offset in the destination array
|
|
|
+ * @returns the current Vector3
|
|
|
+ */
|
|
|
+ Vector2.prototype.fromArray = function (array, index) {
|
|
|
+ if (index === void 0) { index = 0; }
|
|
|
+ Vector2.FromArrayToRef(array, index, this);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Copy the current vector to an array
|
|
|
* @returns a new array with 2 elements: the Vector2 coordinates.
|
|
|
*/
|
|
@@ -107427,6 +107515,17 @@ var Vector3 = /** @class */ (function () {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Update the current vector from an array
|
|
|
+ * @param array defines the destination array
|
|
|
+ * @param index defines the offset in the destination array
|
|
|
+ * @returns the current Vector3
|
|
|
+ */
|
|
|
+ Vector3.prototype.fromArray = function (array, index) {
|
|
|
+ if (index === void 0) { index = 0; }
|
|
|
+ Vector3.FromArrayToRef(array, index, this);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
|
|
|
* @returns a new Quaternion object, computed from the Vector3 coordinates
|
|
|
*/
|
|
@@ -108633,6 +108732,17 @@ var Vector4 = /** @class */ (function () {
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Update the current vector from an array
|
|
|
+ * @param array defines the destination array
|
|
|
+ * @param index defines the offset in the destination array
|
|
|
+ * @returns the current Vector3
|
|
|
+ */
|
|
|
+ Vector4.prototype.fromArray = function (array, index) {
|
|
|
+ if (index === void 0) { index = 0; }
|
|
|
+ Vector4.FromArrayToRef(array, index, this);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Adds the given vector to the current Vector4.
|
|
|
* @param otherVector the vector to add
|
|
|
* @returns the updated Vector4.
|
|
@@ -125699,6 +125809,7 @@ var Mesh = /** @class */ (function (_super) {
|
|
|
Mesh.prototype.serialize = function (serializationObject) {
|
|
|
serializationObject.name = this.name;
|
|
|
serializationObject.id = this.id;
|
|
|
+ serializationObject.uniqueId = this.uniqueId;
|
|
|
serializationObject.type = this.getClassName();
|
|
|
if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
|
|
|
serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
|
|
@@ -138001,6 +138112,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var _dataStorage__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ./dataStorage */ "./Misc/dataStorage.ts");
|
|
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataStorage", function() { return _dataStorage__WEBPACK_IMPORTED_MODULE_48__["DataStorage"]; });
|
|
|
|
|
|
+/* harmony import */ var _sceneRecorder__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ./sceneRecorder */ "./Misc/sceneRecorder.ts");
|
|
|
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneRecorder", function() { return _sceneRecorder__WEBPACK_IMPORTED_MODULE_49__["SceneRecorder"]; });
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -141005,6 +141120,276 @@ var SceneOptimizer = /** @class */ (function () {
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
+/***/ "./Misc/sceneRecorder.ts":
|
|
|
+/*!*******************************!*\
|
|
|
+ !*** ./Misc/sceneRecorder.ts ***!
|
|
|
+ \*******************************/
|
|
|
+/*! exports provided: SceneRecorder */
|
|
|
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
+
|
|
|
+"use strict";
|
|
|
+__webpack_require__.r(__webpack_exports__);
|
|
|
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneRecorder", function() { return SceneRecorder; });
|
|
|
+/* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
|
|
|
+/* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
|
|
|
+/* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
|
|
|
+/* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
|
|
|
+/* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Bones/skeleton */ "./Bones/skeleton.ts");
|
|
|
+/* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
|
|
|
+/* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
|
|
|
+/* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
|
|
|
+/* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
|
|
|
+/* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Class used to record delta files between 2 scene states
|
|
|
+ */
|
|
|
+var SceneRecorder = /** @class */ (function () {
|
|
|
+ function SceneRecorder() {
|
|
|
+ this._trackedScene = null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Track a given scene. This means the current scene state will be considered the original state
|
|
|
+ * @param scene defines the scene to track
|
|
|
+ */
|
|
|
+ SceneRecorder.prototype.track = function (scene) {
|
|
|
+ this._trackedScene = scene;
|
|
|
+ this._savedJSON = _sceneSerializer__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"].Serialize(scene);
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Get the delta between current state and original state
|
|
|
+ * @returns a string containing the delta
|
|
|
+ */
|
|
|
+ SceneRecorder.prototype.getDelta = function () {
|
|
|
+ if (!this._trackedScene) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ var newJSON = _sceneSerializer__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"].Serialize(this._trackedScene);
|
|
|
+ var deltaJSON = {};
|
|
|
+ for (var node in newJSON) {
|
|
|
+ console.log("Processing " + node);
|
|
|
+ this._compareCollections(node, this._savedJSON[node], newJSON[node], deltaJSON);
|
|
|
+ }
|
|
|
+ return deltaJSON;
|
|
|
+ };
|
|
|
+ SceneRecorder.prototype._compareArray = function (key, original, current, deltaJSON) {
|
|
|
+ if (original.length === 0 && current.length === 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // Numbers?
|
|
|
+ if (original.length && !isNaN(original[0]) || current.length && !isNaN(current[0])) {
|
|
|
+ if (original.length !== current.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (original.length === 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ for (var index = 0; index < original.length; index++) {
|
|
|
+ if (original[index] !== current[index]) {
|
|
|
+ deltaJSON[key] = current;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // let's use uniqueId to find similar objects
|
|
|
+ var originalUniqueIds = [];
|
|
|
+ var _loop_1 = function () {
|
|
|
+ var originalObject = original[index];
|
|
|
+ var originalUniqueId = originalObject.uniqueId;
|
|
|
+ originalUniqueIds.push(originalUniqueId);
|
|
|
+ // Look for that object in current state
|
|
|
+ var currentObjects = current.filter(function (c) { return c.uniqueId === originalUniqueId; });
|
|
|
+ if (currentObjects.length) { // We have a candidate
|
|
|
+ var currentObject = currentObjects[0];
|
|
|
+ var newObject = {};
|
|
|
+ if (!this_1._compareObjects(originalObject, currentObject, newObject)) {
|
|
|
+ if (!deltaJSON[key]) {
|
|
|
+ deltaJSON[key] = [];
|
|
|
+ }
|
|
|
+ newObject.__state = {
|
|
|
+ id: currentObject.id
|
|
|
+ };
|
|
|
+ deltaJSON[key].push(newObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // We need to delete
|
|
|
+ var newObject = {
|
|
|
+ __state: {
|
|
|
+ deleteId: originalObject.id
|
|
|
+ }
|
|
|
+ };
|
|
|
+ deltaJSON[key].push(newObject);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ var this_1 = this;
|
|
|
+ for (var index = 0; index < original.length; index++) {
|
|
|
+ _loop_1();
|
|
|
+ }
|
|
|
+ // Checking for new objects
|
|
|
+ for (var index = 0; index < current.length; index++) {
|
|
|
+ var currentObject = current[index];
|
|
|
+ var currentUniqueId = currentObject.uniqueId;
|
|
|
+ // Object was added
|
|
|
+ if (originalUniqueIds.indexOf(currentUniqueId) === -1) {
|
|
|
+ if (!deltaJSON[key]) {
|
|
|
+ deltaJSON[key] = [];
|
|
|
+ }
|
|
|
+ deltaJSON[key].push(currentObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ SceneRecorder.prototype._compareObjects = function (originalObjet, currentObject, deltaJSON) {
|
|
|
+ var aDifferenceWasFound = false;
|
|
|
+ for (var prop in originalObjet) {
|
|
|
+ if (!originalObjet.hasOwnProperty(prop)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ var originalValue = originalObjet[prop];
|
|
|
+ var currentValue = currentObject[prop];
|
|
|
+ var diffFound = false;
|
|
|
+ if (Array.isArray(originalValue)) {
|
|
|
+ diffFound = (JSON.stringify(originalValue) !== JSON.stringify(currentValue));
|
|
|
+ }
|
|
|
+ else if (!isNaN(originalValue) || Object.prototype.toString.call(originalValue) == '[object String]') {
|
|
|
+ diffFound = (originalValue !== currentValue);
|
|
|
+ }
|
|
|
+ if (diffFound) {
|
|
|
+ aDifferenceWasFound = true;
|
|
|
+ deltaJSON[prop] = currentValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return !aDifferenceWasFound;
|
|
|
+ };
|
|
|
+ SceneRecorder.prototype._compareCollections = function (key, original, current, deltaJSON) {
|
|
|
+ console.log(original, typeof original);
|
|
|
+ console.log(current, typeof current);
|
|
|
+ // Same ?
|
|
|
+ if (original === current) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (original && current) {
|
|
|
+ // Array?
|
|
|
+ if (Array.isArray(original) && Array.isArray(current)) {
|
|
|
+ if (this._compareArray(key, original, current, deltaJSON)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (typeof original === "object" && typeof current === "object") { // Object
|
|
|
+ var newObject = {};
|
|
|
+ if (!this._compareObjects(original, current, newObject)) {
|
|
|
+ deltaJSON[key] = newObject;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Apply a given delta to a given scene
|
|
|
+ * @param deltaJSON defines the JSON containing the delta
|
|
|
+ * @param scene defines the scene to apply the delta to
|
|
|
+ */
|
|
|
+ SceneRecorder.ApplyDelta = function (deltaJSON, scene) {
|
|
|
+ if (deltaJSON.toString) {
|
|
|
+ deltaJSON = JSON.parse(deltaJSON);
|
|
|
+ }
|
|
|
+ // Scene
|
|
|
+ var anyScene = scene;
|
|
|
+ for (var prop in deltaJSON) {
|
|
|
+ var source = deltaJSON[prop];
|
|
|
+ var property = anyScene[prop];
|
|
|
+ if (Array.isArray(property)) { // Restore array
|
|
|
+ switch (prop) {
|
|
|
+ case "cameras":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getCameraByID.bind(scene), function (data) { return _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].Parse(data, scene); });
|
|
|
+ break;
|
|
|
+ case "lights":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getLightByID.bind(scene), function (data) { return _Lights_light__WEBPACK_IMPORTED_MODULE_2__["Light"].Parse(data, scene); });
|
|
|
+ break;
|
|
|
+ case "meshes":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getMeshByID.bind(scene), function (data) { return _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].Parse(data, scene, ""); });
|
|
|
+ break;
|
|
|
+ case "skeletons":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getSkeletonById.bind(scene), function (data) { return _Bones_skeleton__WEBPACK_IMPORTED_MODULE_4__["Skeleton"].Parse(data, scene); });
|
|
|
+ break;
|
|
|
+ case "materials":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getMaterialByID.bind(scene), function (data) { return _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].Parse(data, scene, ""); });
|
|
|
+ break;
|
|
|
+ case "multiMaterials":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getMaterialByID.bind(scene), function (data) { return _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_6__["MultiMaterial"].Parse(data, scene, ""); });
|
|
|
+ break;
|
|
|
+ case "transformNodes":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getTransformNodeByID.bind(scene), function (data) { return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].Parse(data, scene, ""); });
|
|
|
+ break;
|
|
|
+ case "particleSystems":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getParticleSystemByID.bind(scene), function (data) { return _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_8__["ParticleSystem"].Parse(data, scene, ""); });
|
|
|
+ break;
|
|
|
+ case "morphTargetManagers":
|
|
|
+ this._ApplyDeltaForEntity(source, scene, scene.getMorphTargetById.bind(scene), function (data) { return _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_9__["MorphTargetManager"].Parse(data, scene); });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (!isNaN(property)) {
|
|
|
+ anyScene[prop] = source;
|
|
|
+ }
|
|
|
+ else if (property.fromArray) {
|
|
|
+ property.fromArray(source);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ SceneRecorder._ApplyPropertiesToEntity = function (deltaJSON, entity) {
|
|
|
+ for (var prop in deltaJSON) {
|
|
|
+ var source = deltaJSON[prop];
|
|
|
+ var property = entity[prop];
|
|
|
+ if (property === undefined) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!isNaN(property) || Array.isArray(property)) {
|
|
|
+ entity[prop] = source;
|
|
|
+ }
|
|
|
+ else if (property.fromArray) {
|
|
|
+ property.fromArray(source);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ SceneRecorder._ApplyDeltaForEntity = function (sources, scene, finder, addNew) {
|
|
|
+ for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
|
|
|
+ var source = sources_1[_i];
|
|
|
+ // Update
|
|
|
+ if (source.__state && source.__state.id !== undefined) {
|
|
|
+ var targetEntity = finder(source.__state.id);
|
|
|
+ if (targetEntity) {
|
|
|
+ this._ApplyPropertiesToEntity(source, targetEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (source.__state && source.__state.deleteId !== undefined) {
|
|
|
+ var target = finder(source.__state.deleteId);
|
|
|
+ target === null || target === void 0 ? void 0 : target.dispose();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // New
|
|
|
+ addNew(source);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return SceneRecorder;
|
|
|
+}());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/***/ }),
|
|
|
+
|
|
|
/***/ "./Misc/sceneSerializer.ts":
|
|
|
/*!*********************************!*\
|
|
|
!*** ./Misc/sceneSerializer.ts ***!
|
|
@@ -182894,7 +183279,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
return;
|
|
|
}
|
|
|
// only support tracker pointer
|
|
|
- var _a = _this._generateNewMeshPair(xrController), laserPointer = _a.laserPointer, selectionMesh = _a.selectionMesh;
|
|
|
+ var _a = _this._generateNewMeshPair(xrController.pointer), laserPointer = _a.laserPointer, selectionMesh = _a.selectionMesh;
|
|
|
// get two new meshes
|
|
|
_this._controllers[xrController.uniqueId] = {
|
|
|
xrController: xrController,
|
|
@@ -182969,6 +183354,20 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
_this._detachController(controller.uniqueId);
|
|
|
});
|
|
|
this._scene.constantlyUpdateMeshUnderPointer = true;
|
|
|
+ if (this._options.gazeCamera) {
|
|
|
+ var webXRCamera = this._options.gazeCamera;
|
|
|
+ var _a = this._generateNewMeshPair(webXRCamera), laserPointer = _a.laserPointer, selectionMesh = _a.selectionMesh;
|
|
|
+ this._controllers["camera"] = {
|
|
|
+ webXRCamera: webXRCamera,
|
|
|
+ laserPointer: laserPointer,
|
|
|
+ selectionMesh: selectionMesh,
|
|
|
+ meshUnderPointer: null,
|
|
|
+ pick: null,
|
|
|
+ tmpRay: new _Culling_ray__WEBPACK_IMPORTED_MODULE_8__["Ray"](new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](), new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"]()),
|
|
|
+ id: WebXRControllerPointerSelection._idCounter++,
|
|
|
+ };
|
|
|
+ this._attachGazeMode();
|
|
|
+ }
|
|
|
return true;
|
|
|
};
|
|
|
/**
|
|
@@ -183011,7 +183410,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
var keys = Object.keys(this._controllers);
|
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
|
if (this._controllers[keys[i]].id === id) {
|
|
|
- return this._controllers[keys[i]].xrController;
|
|
|
+ return this._controllers[keys[i]].xrController || null;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -183021,7 +183420,15 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
Object.keys(this._controllers).forEach(function (id) {
|
|
|
var controllerData = _this._controllers[id];
|
|
|
// Every frame check collisions/input
|
|
|
- controllerData.xrController.getWorldPointerRayToRef(controllerData.tmpRay);
|
|
|
+ if (controllerData.xrController) {
|
|
|
+ controllerData.xrController.getWorldPointerRayToRef(controllerData.tmpRay);
|
|
|
+ }
|
|
|
+ else if (controllerData.webXRCamera) {
|
|
|
+ controllerData.webXRCamera.getForwardRayToRef(controllerData.tmpRay);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
controllerData.pick = _this._scene.pickWithRay(controllerData.tmpRay, _this._scene.pointerMovePredicate || _this.raySelectionPredicate);
|
|
|
var pick = controllerData.pick;
|
|
|
if (pick && pick.pickedPoint && pick.hit) {
|
|
@@ -183053,7 +183460,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
};
|
|
|
WebXRControllerPointerSelection.prototype._attachGazeMode = function (xrController) {
|
|
|
var _this = this;
|
|
|
- var controllerData = this._controllers[xrController.uniqueId];
|
|
|
+ var controllerData = this._controllers[(xrController && xrController.uniqueId) || "camera"];
|
|
|
// attached when touched, detaches when raised
|
|
|
var timeToSelect = this._options.timeToSelect || 3000;
|
|
|
var sceneToRenderTo = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultUtilityLayer.utilityLayerScene : this._scene;
|
|
@@ -183114,12 +183521,14 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
if (this._options.renderingGroupId !== undefined) {
|
|
|
discMesh.renderingGroupId = this._options.renderingGroupId;
|
|
|
}
|
|
|
- xrController.onDisposeObservable.addOnce(function () {
|
|
|
- if (controllerData.pick && !_this._options.disablePointerUpOnTouchOut && downTriggered) {
|
|
|
- _this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
- }
|
|
|
- discMesh.dispose();
|
|
|
- });
|
|
|
+ if (xrController) {
|
|
|
+ xrController.onDisposeObservable.addOnce(function () {
|
|
|
+ if (controllerData.pick && !_this._options.disablePointerUpOnTouchOut && downTriggered) {
|
|
|
+ _this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
+ }
|
|
|
+ discMesh.dispose();
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
WebXRControllerPointerSelection.prototype._attachScreenRayMode = function (xrController) {
|
|
|
var _this = this;
|
|
@@ -183196,14 +183605,14 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
else {
|
|
|
// use the select and squeeze events
|
|
|
var selectStartListener = function (event) {
|
|
|
- if (event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
+ if (controllerData.xrController && event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
_this._scene.simulatePointerDown(controllerData.pick, { pointerId: controllerData.id });
|
|
|
controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshPickedColor;
|
|
|
controllerData.laserPointer.material.emissiveColor = _this.laserPointerPickedColor;
|
|
|
}
|
|
|
};
|
|
|
var selectEndListener = function (event) {
|
|
|
- if (event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
+ if (controllerData.xrController && event.inputSource === controllerData.xrController.inputSource && controllerData.pick) {
|
|
|
_this._scene.simulatePointerUp(controllerData.pick, { pointerId: controllerData.id });
|
|
|
controllerData.selectionMesh.material.emissiveColor = _this.selectionMeshDefaultColor;
|
|
|
controllerData.laserPointer.material.emissiveColor = _this.laserPointerDefaultColor;
|
|
@@ -183253,7 +183662,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
// remove from the map
|
|
|
delete this._controllers[xrControllerUniqueId];
|
|
|
};
|
|
|
- WebXRControllerPointerSelection.prototype._generateNewMeshPair = function (xrController) {
|
|
|
+ WebXRControllerPointerSelection.prototype._generateNewMeshPair = function (meshParent) {
|
|
|
var sceneToRenderTo = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultUtilityLayer.utilityLayerScene : this._scene;
|
|
|
var laserPointer = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_6__["CylinderBuilder"].CreateCylinder("laserPointer", {
|
|
|
height: 1,
|
|
@@ -183262,7 +183671,7 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
tessellation: 20,
|
|
|
subdivisions: 1,
|
|
|
}, sceneToRenderTo);
|
|
|
- laserPointer.parent = xrController.pointer;
|
|
|
+ laserPointer.parent = meshParent;
|
|
|
var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("laserPointerMat", sceneToRenderTo);
|
|
|
laserPointerMaterial.emissiveColor = this.laserPointerDefaultColor;
|
|
|
laserPointerMaterial.alpha = 0.7;
|
|
@@ -183308,7 +183717,6 @@ var WebXRControllerPointerSelection = /** @class */ (function (_super) {
|
|
|
this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
|
|
|
var delta = (this._options.gazeModePointerMovedFactor || 1) * 0.01 * newPick.distance;
|
|
|
var length = this._tmpVectorForPickCompare.length();
|
|
|
- console.log(delta, length, newPick.distance);
|
|
|
if (length > delta) {
|
|
|
return true;
|
|
|
}
|