|
@@ -9596,6 +9596,68 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.promise.js.map
|
|
|
|
|
|
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Helper class to push actions to a pool of workers.
|
|
|
+ */
|
|
|
+ var WorkerPool = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Constructor
|
|
|
+ * @param workers Array of workers to use for actions
|
|
|
+ */
|
|
|
+ function WorkerPool(workers) {
|
|
|
+ this._pendingActions = new Array();
|
|
|
+ this._workerInfos = workers.map(function (worker) { return ({
|
|
|
+ worker: worker,
|
|
|
+ active: false
|
|
|
+ }); });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Terminates all workers and clears any pending actions.
|
|
|
+ */
|
|
|
+ WorkerPool.prototype.dispose = function () {
|
|
|
+ for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
|
|
|
+ var workerInfo = _a[_i];
|
|
|
+ workerInfo.worker.terminate();
|
|
|
+ }
|
|
|
+ delete this._workerInfos;
|
|
|
+ delete this._pendingActions;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Pushes an action to the worker pool. If all the workers are active, the action will be
|
|
|
+ * pended until a worker has completed its action.
|
|
|
+ * @param action The action to perform. Call onComplete when the action is complete.
|
|
|
+ */
|
|
|
+ WorkerPool.prototype.push = function (action) {
|
|
|
+ for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
|
|
|
+ var workerInfo = _a[_i];
|
|
|
+ if (!workerInfo.active) {
|
|
|
+ this._execute(workerInfo, action);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this._pendingActions.push(action);
|
|
|
+ };
|
|
|
+ WorkerPool.prototype._execute = function (workerInfo, action) {
|
|
|
+ var _this = this;
|
|
|
+ workerInfo.active = true;
|
|
|
+ action(workerInfo.worker, function () {
|
|
|
+ workerInfo.active = false;
|
|
|
+ var nextAction = _this._pendingActions.shift();
|
|
|
+ if (nextAction) {
|
|
|
+ _this._execute(workerInfo, nextAction);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ return WorkerPool;
|
|
|
+ }());
|
|
|
+ BABYLON.WorkerPool = WorkerPool;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.workerPool.js.map
|
|
|
+
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
var _AlphaState = /** @class */ (function () {
|
|
@@ -21407,6 +21469,7 @@ var BABYLON;
|
|
|
this._useAlternateCameraConfiguration = false;
|
|
|
this._alternateRendering = false;
|
|
|
this.requireLightSorting = false;
|
|
|
+ this._depthRenderer = {};
|
|
|
this._activeMeshesFrozen = false;
|
|
|
this._tempPickingRay = BABYLON.Ray ? BABYLON.Ray.Zero() : null;
|
|
|
this._engine = engine || BABYLON.Engine.LastCreatedEngine;
|
|
@@ -24185,8 +24248,8 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
// Depth renderer
|
|
|
- if (this._depthRenderer) {
|
|
|
- this._renderTargets.push(this._depthRenderer.getDepthMap());
|
|
|
+ for (var key in this._depthRenderer) {
|
|
|
+ this._renderTargets.push(this._depthRenderer[key].getDepthMap());
|
|
|
}
|
|
|
// Geometry renderer
|
|
|
if (this._geometryBufferRenderer) {
|
|
@@ -24355,19 +24418,32 @@ var BABYLON;
|
|
|
this.soundTracks[i].switchPanningModelToEqualPower();
|
|
|
}
|
|
|
};
|
|
|
- Scene.prototype.enableDepthRenderer = function () {
|
|
|
- if (this._depthRenderer) {
|
|
|
- return this._depthRenderer;
|
|
|
+ /**
|
|
|
+ * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
|
|
|
+ * @param camera The camera to create the depth renderer on (default: scene's active camera)
|
|
|
+ * @returns the created depth renderer
|
|
|
+ */
|
|
|
+ Scene.prototype.enableDepthRenderer = function (camera) {
|
|
|
+ camera = camera || this.activeCamera;
|
|
|
+ if (!camera) {
|
|
|
+ throw "No camera available to enable depth renderer";
|
|
|
}
|
|
|
- this._depthRenderer = new BABYLON.DepthRenderer(this);
|
|
|
- return this._depthRenderer;
|
|
|
+ if (!this._depthRenderer[camera.id]) {
|
|
|
+ this._depthRenderer[camera.id] = new BABYLON.DepthRenderer(this, BABYLON.Engine.TEXTURETYPE_FLOAT, camera);
|
|
|
+ }
|
|
|
+ return this._depthRenderer[camera.id];
|
|
|
};
|
|
|
- Scene.prototype.disableDepthRenderer = function () {
|
|
|
- if (!this._depthRenderer) {
|
|
|
+ /**
|
|
|
+ * Disables a depth renderer for a given camera
|
|
|
+ * @param camera The camera to disable the depth renderer on (default: scene's active camera)
|
|
|
+ */
|
|
|
+ Scene.prototype.disableDepthRenderer = function (camera) {
|
|
|
+ camera = camera || this.activeCamera;
|
|
|
+ if (!camera || !this._depthRenderer[camera.id]) {
|
|
|
return;
|
|
|
}
|
|
|
- this._depthRenderer.dispose();
|
|
|
- this._depthRenderer = null;
|
|
|
+ this._depthRenderer[camera.id].dispose();
|
|
|
+ delete this._depthRenderer[camera.id];
|
|
|
};
|
|
|
Scene.prototype.enableGeometryBufferRenderer = function (ratio) {
|
|
|
if (ratio === void 0) { ratio = 1; }
|
|
@@ -24405,8 +24481,8 @@ var BABYLON;
|
|
|
this.importedMeshesFiles = new Array();
|
|
|
this.stopAllAnimations();
|
|
|
this.resetCachedMaterial();
|
|
|
- if (this._depthRenderer) {
|
|
|
- this._depthRenderer.dispose();
|
|
|
+ for (var key in this._depthRenderer) {
|
|
|
+ this._depthRenderer[key].dispose();
|
|
|
}
|
|
|
if (this._gamepadManager) {
|
|
|
this._gamepadManager.dispose();
|
|
@@ -24569,21 +24645,27 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
// Octrees
|
|
|
- Scene.prototype.getWorldExtends = function () {
|
|
|
+ /**
|
|
|
+ * Get the world extend vectors with an optional filter
|
|
|
+ *
|
|
|
+ * @param filterPredicate the predicate - which meshes should be included when calculating the world size
|
|
|
+ * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
|
|
|
+ */
|
|
|
+ Scene.prototype.getWorldExtends = function (filterPredicate) {
|
|
|
var min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
|
var max = new BABYLON.Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
|
|
|
- for (var index = 0; index < this.meshes.length; index++) {
|
|
|
- var mesh = this.meshes[index];
|
|
|
+ filterPredicate = filterPredicate || (function () { return true; });
|
|
|
+ this.meshes.filter(filterPredicate).forEach(function (mesh) {
|
|
|
mesh.computeWorldMatrix(true);
|
|
|
if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
|
|
|
- continue;
|
|
|
+ return;
|
|
|
}
|
|
|
var boundingInfo = mesh.getBoundingInfo();
|
|
|
var minBox = boundingInfo.boundingBox.minimumWorld;
|
|
|
var maxBox = boundingInfo.boundingBox.maximumWorld;
|
|
|
BABYLON.Tools.CheckExtends(minBox, min, max);
|
|
|
BABYLON.Tools.CheckExtends(maxBox, min, max);
|
|
|
- }
|
|
|
+ });
|
|
|
return {
|
|
|
min: min,
|
|
|
max: max
|
|
@@ -56463,96 +56545,167 @@ var BABYLON;
|
|
|
* Draco compression (https://google.github.io/draco/)
|
|
|
*/
|
|
|
var DracoCompression = /** @class */ (function () {
|
|
|
- function DracoCompression() {
|
|
|
+ /**
|
|
|
+ * Constructor
|
|
|
+ * @param numWorkers The number of workers for async operations
|
|
|
+ */
|
|
|
+ function DracoCompression(numWorkers) {
|
|
|
+ if (numWorkers === void 0) { numWorkers = (navigator.hardwareConcurrency || 4); }
|
|
|
+ var workers = new Array(numWorkers);
|
|
|
+ for (var i = 0; i < workers.length; i++) {
|
|
|
+ var worker = new Worker(DracoCompression._WorkerBlobUrl);
|
|
|
+ worker.postMessage({ id: "initDecoder", url: DracoCompression.DecoderUrl });
|
|
|
+ workers[i] = worker;
|
|
|
+ }
|
|
|
+ this._workerPool = new BABYLON.WorkerPool(workers);
|
|
|
}
|
|
|
- Object.defineProperty(DracoCompression, "IsSupported", {
|
|
|
- /**
|
|
|
- * Returns whether Draco compression is supported.
|
|
|
- */
|
|
|
- get: function () {
|
|
|
- return BABYLON.Tools.IsWindowObjectExist() && !!window.DracoDecoderModule;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
/**
|
|
|
- * Decodes Draco compressed data to vertex data.
|
|
|
+ * Stop all async operations and release resources.
|
|
|
+ */
|
|
|
+ DracoCompression.prototype.dispose = function () {
|
|
|
+ this._workerPool.dispose();
|
|
|
+ delete this._workerPool;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Decode Draco compressed mesh data to vertex data.
|
|
|
* @param data The array buffer view for the Draco compression data
|
|
|
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
|
- * @returns The decoded vertex data
|
|
|
- */
|
|
|
- DracoCompression.Decode = function (data, attributes) {
|
|
|
- var dracoModule = new DracoDecoderModule();
|
|
|
- var buffer = new dracoModule.DecoderBuffer();
|
|
|
- buffer.Init(data, data.byteLength);
|
|
|
- var decoder = new dracoModule.Decoder();
|
|
|
- var geometry;
|
|
|
- var status;
|
|
|
- var vertexData = new BABYLON.VertexData();
|
|
|
- try {
|
|
|
- var type = decoder.GetEncodedGeometryType(buffer);
|
|
|
- switch (type) {
|
|
|
- case dracoModule.TRIANGULAR_MESH:
|
|
|
- geometry = new dracoModule.Mesh();
|
|
|
- status = decoder.DecodeBufferToMesh(buffer, geometry);
|
|
|
- break;
|
|
|
- case dracoModule.POINT_CLOUD:
|
|
|
- geometry = new dracoModule.PointCloud();
|
|
|
- status = decoder.DecodeBufferToPointCloud(buffer, geometry);
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new Error("Invalid geometry type " + type);
|
|
|
- }
|
|
|
- if (!status.ok() || !geometry.ptr) {
|
|
|
- throw new Error(status.error_msg());
|
|
|
- }
|
|
|
- var numPoints = geometry.num_points();
|
|
|
- if (type === dracoModule.TRIANGULAR_MESH) {
|
|
|
- var numFaces = geometry.num_faces();
|
|
|
- var faceIndices = new dracoModule.DracoInt32Array();
|
|
|
- try {
|
|
|
- vertexData.indices = new Uint32Array(numFaces * 3);
|
|
|
- for (var i = 0; i < numFaces; i++) {
|
|
|
- decoder.GetFaceFromMesh(geometry, i, faceIndices);
|
|
|
- var offset = i * 3;
|
|
|
- vertexData.indices[offset + 0] = faceIndices.GetValue(0);
|
|
|
- vertexData.indices[offset + 1] = faceIndices.GetValue(1);
|
|
|
- vertexData.indices[offset + 2] = faceIndices.GetValue(2);
|
|
|
+ * @returns A promise that resolves with the decoded vertex data
|
|
|
+ */
|
|
|
+ DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
|
|
|
+ var _this = this;
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ _this._workerPool.push(function (worker, onComplete) {
|
|
|
+ var vertexData = new BABYLON.VertexData();
|
|
|
+ var onError = function (error) {
|
|
|
+ worker.removeEventListener("error", onError);
|
|
|
+ worker.removeEventListener("message", onMessage);
|
|
|
+ reject(error);
|
|
|
+ onComplete();
|
|
|
+ };
|
|
|
+ var onMessage = function (message) {
|
|
|
+ if (message.data === "done") {
|
|
|
+ worker.removeEventListener("error", onError);
|
|
|
+ worker.removeEventListener("message", onMessage);
|
|
|
+ resolve(vertexData);
|
|
|
+ onComplete();
|
|
|
+ }
|
|
|
+ else if (message.data.id === "indices") {
|
|
|
+ vertexData.indices = message.data.value;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ vertexData.set(message.data.value, message.data.id);
|
|
|
}
|
|
|
+ };
|
|
|
+ worker.addEventListener("error", onError);
|
|
|
+ worker.addEventListener("message", onMessage);
|
|
|
+ var dataCopy = new Uint8Array(data.byteLength);
|
|
|
+ dataCopy.set(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
|
+ worker.postMessage({ id: "decodeMesh", data: dataCopy, attributes: attributes }, [dataCopy.buffer]);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * The worker function that gets converted to a blob url to pass into a worker.
|
|
|
+ */
|
|
|
+ DracoCompression._Worker = function () {
|
|
|
+ // self is actually a DedicatedWorkerGlobalScope
|
|
|
+ var _self = self;
|
|
|
+ var decodeMesh = function (data, attributes) {
|
|
|
+ var dracoModule = new DracoDecoderModule();
|
|
|
+ var buffer = new dracoModule.DecoderBuffer();
|
|
|
+ buffer.Init(data, data.byteLength);
|
|
|
+ var decoder = new dracoModule.Decoder();
|
|
|
+ var geometry;
|
|
|
+ var status;
|
|
|
+ try {
|
|
|
+ var type = decoder.GetEncodedGeometryType(buffer);
|
|
|
+ switch (type) {
|
|
|
+ case dracoModule.TRIANGULAR_MESH:
|
|
|
+ geometry = new dracoModule.Mesh();
|
|
|
+ status = decoder.DecodeBufferToMesh(buffer, geometry);
|
|
|
+ break;
|
|
|
+ case dracoModule.POINT_CLOUD:
|
|
|
+ geometry = new dracoModule.PointCloud();
|
|
|
+ status = decoder.DecodeBufferToPointCloud(buffer, geometry);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new Error("Invalid geometry type " + type);
|
|
|
}
|
|
|
- finally {
|
|
|
- dracoModule.destroy(faceIndices);
|
|
|
+ if (!status.ok() || !geometry.ptr) {
|
|
|
+ throw new Error(status.error_msg());
|
|
|
}
|
|
|
- }
|
|
|
- for (var kind in attributes) {
|
|
|
- var uniqueId = attributes[kind];
|
|
|
- var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
|
|
|
- var dracoData = new dracoModule.DracoFloat32Array();
|
|
|
- try {
|
|
|
- if (attribute.num_components() !== BABYLON.VertexBuffer.DeduceStride(kind)) {
|
|
|
- throw new Error("Unsupported number of components for " + kind);
|
|
|
+ var numPoints = geometry.num_points();
|
|
|
+ if (type === dracoModule.TRIANGULAR_MESH) {
|
|
|
+ var numFaces = geometry.num_faces();
|
|
|
+ var faceIndices = new dracoModule.DracoInt32Array();
|
|
|
+ try {
|
|
|
+ var indices = new Uint32Array(numFaces * 3);
|
|
|
+ for (var i = 0; i < numFaces; i++) {
|
|
|
+ decoder.GetFaceFromMesh(geometry, i, faceIndices);
|
|
|
+ var offset = i * 3;
|
|
|
+ indices[offset + 0] = faceIndices.GetValue(0);
|
|
|
+ indices[offset + 1] = faceIndices.GetValue(1);
|
|
|
+ indices[offset + 2] = faceIndices.GetValue(2);
|
|
|
+ }
|
|
|
+ _self.postMessage({ id: "indices", value: indices }, [indices.buffer]);
|
|
|
}
|
|
|
- decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
|
|
|
- var babylonData = new Float32Array(numPoints * attribute.num_components());
|
|
|
- for (var i = 0; i < babylonData.length; i++) {
|
|
|
- babylonData[i] = dracoData.GetValue(i);
|
|
|
+ finally {
|
|
|
+ dracoModule.destroy(faceIndices);
|
|
|
}
|
|
|
- vertexData.set(babylonData, kind);
|
|
|
}
|
|
|
- finally {
|
|
|
- dracoModule.destroy(dracoData);
|
|
|
+ for (var kind in attributes) {
|
|
|
+ var uniqueId = attributes[kind];
|
|
|
+ var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
|
|
|
+ var dracoData = new dracoModule.DracoFloat32Array();
|
|
|
+ try {
|
|
|
+ decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
|
|
|
+ var babylonData = new Float32Array(numPoints * attribute.num_components());
|
|
|
+ for (var i = 0; i < babylonData.length; i++) {
|
|
|
+ babylonData[i] = dracoData.GetValue(i);
|
|
|
+ }
|
|
|
+ _self.postMessage({ id: kind, value: babylonData }, [babylonData.buffer]);
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ dracoModule.destroy(dracoData);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- finally {
|
|
|
- if (geometry) {
|
|
|
- dracoModule.destroy(geometry);
|
|
|
+ finally {
|
|
|
+ if (geometry) {
|
|
|
+ dracoModule.destroy(geometry);
|
|
|
+ }
|
|
|
+ dracoModule.destroy(decoder);
|
|
|
+ dracoModule.destroy(buffer);
|
|
|
+ }
|
|
|
+ _self.postMessage("done");
|
|
|
+ };
|
|
|
+ _self.onmessage = function (event) {
|
|
|
+ switch (event.data.id) {
|
|
|
+ case "initDecoder": {
|
|
|
+ importScripts(event.data.url);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "decodeMesh": {
|
|
|
+ decodeMesh(event.data.data, event.data.attributes);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ };
|
|
|
+ DracoCompression._GetDefaultDecoderUrl = function () {
|
|
|
+ for (var i = 0; i < document.scripts.length; i++) {
|
|
|
+ if (document.scripts[i].type === "text/x-draco-decoder") {
|
|
|
+ return document.scripts[i].src;
|
|
|
}
|
|
|
- dracoModule.destroy(decoder);
|
|
|
- dracoModule.destroy(buffer);
|
|
|
}
|
|
|
- return vertexData;
|
|
|
+ return null;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets the url to the draco decoder if available.
|
|
|
+ */
|
|
|
+ DracoCompression.DecoderUrl = DracoCompression._GetDefaultDecoderUrl();
|
|
|
+ DracoCompression._WorkerBlobUrl = URL.createObjectURL(new Blob(["(" + DracoCompression._Worker.toString() + ")()"], { type: "application/javascript" }));
|
|
|
return DracoCompression;
|
|
|
}());
|
|
|
BABYLON.DracoCompression = DracoCompression;
|
|
@@ -66431,11 +66584,23 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * This represents a depth renderer in Babylon.
|
|
|
+ * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
|
|
|
+ */
|
|
|
var DepthRenderer = /** @class */ (function () {
|
|
|
- function DepthRenderer(scene, type) {
|
|
|
+ /**
|
|
|
+ * Instantiates a depth renderer
|
|
|
+ * @param scene The scene the renderer belongs to
|
|
|
+ * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
|
|
|
+ * @param camera The camera to be used to render the depth map (default: scene's active camera)
|
|
|
+ */
|
|
|
+ function DepthRenderer(scene, type, camera) {
|
|
|
if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_FLOAT; }
|
|
|
+ if (camera === void 0) { camera = null; }
|
|
|
var _this = this;
|
|
|
this._scene = scene;
|
|
|
+ this._camera = camera;
|
|
|
var engine = scene.getEngine();
|
|
|
// Render target
|
|
|
this._depthMap = new BABYLON.RenderTargetTexture("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
|
|
@@ -66444,6 +66609,10 @@ var BABYLON;
|
|
|
this._depthMap.refreshRate = 1;
|
|
|
this._depthMap.renderParticles = false;
|
|
|
this._depthMap.renderList = null;
|
|
|
+ // Camera to get depth map from to support multiple concurrent cameras
|
|
|
+ this._depthMap.activeCamera = this._camera;
|
|
|
+ this._depthMap.ignoreCameraViewport = true;
|
|
|
+ this._depthMap.useCameraPostProcesses = false;
|
|
|
// set default depth value to 1.0 (far away)
|
|
|
this._depthMap.onClearObservable.add(function (engine) {
|
|
|
engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
|
|
@@ -66465,11 +66634,12 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
|
|
|
- if (_this.isReady(subMesh, hardwareInstancedRendering) && scene.activeCamera) {
|
|
|
+ var camera = _this._camera || scene.activeCamera;
|
|
|
+ if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
|
|
|
engine.enableEffect(_this._effect);
|
|
|
mesh._bind(subMesh, _this._effect, BABYLON.Material.TriangleFillMode);
|
|
|
_this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
|
- _this._effect.setFloat2("depthValues", scene.activeCamera.minZ, scene.activeCamera.minZ + scene.activeCamera.maxZ);
|
|
|
+ _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
|
|
|
// Alpha test
|
|
|
if (material && material.needAlphaTesting()) {
|
|
|
var alphaTexture = material.getAlphaTestTexture();
|
|
@@ -66503,6 +66673,12 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Creates the depth rendering effect and checks if the effect is ready.
|
|
|
+ * @param subMesh The submesh to be used to render the depth map of
|
|
|
+ * @param useInstances If multiple world instances should be used
|
|
|
+ * @returns if the depth renderer is ready to render the depth map
|
|
|
+ */
|
|
|
DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
|
|
|
var material = subMesh.getMaterial();
|
|
|
if (material.disableDepthWrite) {
|
|
@@ -66553,10 +66729,16 @@ var BABYLON;
|
|
|
}
|
|
|
return this._effect.isReady();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets the texture which the depth map will be written to.
|
|
|
+ * @returns The depth map texture
|
|
|
+ */
|
|
|
DepthRenderer.prototype.getDepthMap = function () {
|
|
|
return this._depthMap;
|
|
|
};
|
|
|
- // Methods
|
|
|
+ /**
|
|
|
+ * Disposes of the depth renderer.
|
|
|
+ */
|
|
|
DepthRenderer.prototype.dispose = function () {
|
|
|
this._depthMap.dispose();
|
|
|
};
|
|
@@ -90152,13 +90334,16 @@ var BABYLON;
|
|
|
* Get the scene sizes according to the setup.
|
|
|
*/
|
|
|
EnvironmentHelper.prototype._getSceneSize = function () {
|
|
|
+ var _this = this;
|
|
|
var groundSize = this._options.groundSize;
|
|
|
var skyboxSize = this._options.skyboxSize;
|
|
|
var rootPosition = this._options.rootPosition;
|
|
|
if (!this._scene.meshes || this._scene.meshes.length === 1) {
|
|
|
return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
|
|
|
}
|
|
|
- var sceneExtends = this._scene.getWorldExtends();
|
|
|
+ var sceneExtends = this._scene.getWorldExtends(function (mesh) {
|
|
|
+ return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
|
|
|
+ });
|
|
|
var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
|
|
|
if (this._options.sizeAuto) {
|
|
|
if (this._scene.activeCamera instanceof BABYLON.ArcRotateCamera &&
|
|
@@ -90789,8 +90974,9 @@ var DefaultViewer = (function (_super) {
|
|
|
this.containerElement.style.position = 'relative';
|
|
|
this.containerElement.style.display = 'flex';
|
|
|
};
|
|
|
- DefaultViewer.prototype.configureModel = function (modelConfiguration) {
|
|
|
- _super.prototype.configureModel.call(this, modelConfiguration);
|
|
|
+ DefaultViewer.prototype.configureModel = function (modelConfiguration, focusMeshes) {
|
|
|
+ if (focusMeshes === void 0) { focusMeshes = this.scene.meshes; }
|
|
|
+ _super.prototype.configureModel.call(this, modelConfiguration, focusMeshes);
|
|
|
var navbar = this.templateManager.getTemplate('navBar');
|
|
|
if (!navbar)
|
|
|
return;
|
|
@@ -91257,6 +91443,7 @@ var AbstractViewer = (function () {
|
|
|
}
|
|
|
};
|
|
|
AbstractViewer.prototype.configureCamera = function (cameraConfig, focusMeshes) {
|
|
|
+ var _this = this;
|
|
|
if (focusMeshes === void 0) { focusMeshes = this.scene.meshes; }
|
|
|
if (!this.scene.activeCamera) {
|
|
|
this.scene.createDefaultCamera(true, true, true);
|
|
@@ -91277,7 +91464,9 @@ var AbstractViewer = (function () {
|
|
|
}
|
|
|
}
|
|
|
;
|
|
|
- var sceneExtends = this.scene.getWorldExtends();
|
|
|
+ var sceneExtends = this.scene.getWorldExtends(function (mesh) {
|
|
|
+ return !_this.environmentHelper || (mesh !== _this.environmentHelper.ground && mesh !== _this.environmentHelper.rootMesh && mesh !== _this.environmentHelper.skybox);
|
|
|
+ });
|
|
|
var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
|
|
|
var sceneDiagonalLenght = sceneDiagonal.length();
|
|
|
if (isFinite(sceneDiagonalLenght))
|
|
@@ -91531,11 +91720,31 @@ var AbstractViewer = (function () {
|
|
|
var _this = this;
|
|
|
if (model === void 0) { model = this.configuration.model; }
|
|
|
if (clearScene === void 0) { clearScene = true; }
|
|
|
- if (!model.url) {
|
|
|
+ var modelUrl = (typeof model === 'string') ? model : model.url;
|
|
|
+ if (!modelUrl) {
|
|
|
return Promise.resolve(this.scene);
|
|
|
}
|
|
|
- this.configuration.model = model;
|
|
|
- var modelUrl = (typeof model === 'string') ? model : model.url;
|
|
|
+ if (this.isLoading) {
|
|
|
+ this.nextLoading = function () {
|
|
|
+ delete _this.nextLoading;
|
|
|
+ _this.loadModel(model, clearScene);
|
|
|
+ };
|
|
|
+ return Promise.resolve(this.scene);
|
|
|
+ }
|
|
|
+ this.isLoading = true;
|
|
|
+ if ((typeof model === 'string')) {
|
|
|
+ if (this.configuration.model && typeof this.configuration.model === 'object') {
|
|
|
+ this.configuration.model.url = model;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (this.configuration.model) {
|
|
|
+ deepmerge(this.configuration.model, model);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.configuration.model = model;
|
|
|
+ }
|
|
|
+ }
|
|
|
var parts = modelUrl.split('/');
|
|
|
var filename = parts.pop();
|
|
|
var base = parts.join('/') + '/';
|
|
@@ -91545,13 +91754,18 @@ var AbstractViewer = (function () {
|
|
|
return _this.initScene();
|
|
|
if (clearScene) {
|
|
|
scene.meshes.forEach(function (mesh) {
|
|
|
- mesh.dispose();
|
|
|
+ if (babylonjs_1.Tags.MatchesQuery(mesh, "viewerMesh")) {
|
|
|
+ mesh.dispose();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
return scene;
|
|
|
}).then(function () {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
_this.lastUsedLoader = babylonjs_1.SceneLoader.ImportMesh(undefined, base, filename, _this.scene, function (meshes) {
|
|
|
+ meshes.forEach(function (mesh) {
|
|
|
+ babylonjs_1.Tags.AddTagsTo(mesh, "viewerMesh");
|
|
|
+ });
|
|
|
resolve(meshes);
|
|
|
}, function (progressEvent) {
|
|
|
_this.onModelLoadProgressObservable.notifyObserversWithPromise(progressEvent);
|
|
@@ -91565,19 +91779,23 @@ var AbstractViewer = (function () {
|
|
|
}).then(function (meshes) {
|
|
|
return _this.onModelLoadedObservable.notifyObserversWithPromise(meshes)
|
|
|
.then(function () {
|
|
|
- _this.configureModel(model, meshes);
|
|
|
+ _this.configureModel(_this.configuration.model || model, meshes);
|
|
|
_this.configureLights(_this.configuration.lights);
|
|
|
if (_this.configuration.camera) {
|
|
|
_this.configureCamera(_this.configuration.camera, meshes);
|
|
|
}
|
|
|
return _this.initEnvironment(meshes);
|
|
|
}).then(function () {
|
|
|
+ _this.isLoading = false;
|
|
|
+ if (_this.nextLoading) {
|
|
|
+ return _this.nextLoading();
|
|
|
+ }
|
|
|
return _this.scene;
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
AbstractViewer.prototype.initEnvironment = function (focusMeshes) {
|
|
|
- if (focusMeshes === void 0) { focusMeshes = []; }
|
|
|
+ if (focusMeshes === void 0) { focusMeshes = this.scene.meshes; }
|
|
|
this.configureEnvironment(this.configuration.skybox, this.configuration.ground);
|
|
|
return Promise.resolve(this.scene);
|
|
|
};
|
|
@@ -104613,7 +104831,10 @@ var Template = (function () {
|
|
|
};
|
|
|
Template.prototype.show = function (visibilityFunction) {
|
|
|
var _this = this;
|
|
|
+ if (this.isHiding)
|
|
|
+ return Promise.resolve(this);
|
|
|
return Promise.resolve().then(function () {
|
|
|
+ _this.isShowing = true;
|
|
|
if (visibilityFunction) {
|
|
|
return visibilityFunction(_this);
|
|
|
}
|
|
@@ -104623,13 +104844,17 @@ var Template = (function () {
|
|
|
}
|
|
|
}).then(function () {
|
|
|
_this.isShown = true;
|
|
|
+ _this.isShowing = false;
|
|
|
_this.onStateChange.notifyObservers(_this);
|
|
|
return _this;
|
|
|
});
|
|
|
};
|
|
|
Template.prototype.hide = function (visibilityFunction) {
|
|
|
var _this = this;
|
|
|
+ if (this.isShowing)
|
|
|
+ return Promise.resolve(this);
|
|
|
return Promise.resolve().then(function () {
|
|
|
+ _this.isHiding = true;
|
|
|
if (visibilityFunction) {
|
|
|
return visibilityFunction(_this);
|
|
|
}
|
|
@@ -104639,6 +104864,7 @@ var Template = (function () {
|
|
|
}
|
|
|
}).then(function () {
|
|
|
_this.isShown = false;
|
|
|
+ _this.isHiding = false;
|
|
|
_this.onStateChange.notifyObservers(_this);
|
|
|
return _this;
|
|
|
});
|