Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions dist/forge.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8288,15 +8288,15 @@ function WorkerWrapper(options) {
try {
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
if (!objURL) throw "";
const worker = new Worker(objURL, {
const worker = new window.Worker(objURL, {
name: options == null ? void 0 : options.name
});
worker.addEventListener("error", () => {
(self.URL || self.webkitURL).revokeObjectURL(objURL);
});
return worker;
} catch (e) {
return new Worker(
return new window.Worker(
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
{
name: options == null ? void 0 : options.name
Expand Down Expand Up @@ -9762,13 +9762,22 @@ function getShaders() {
}
return shaders;
}
function hasSplatMeshInHierarchy(object) {
let found = false;
object.traverse((child) => {
if (child instanceof SplatMesh) {
found = true;
}
});
return found;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove

const MAX_ACCUMULATORS = 5;
let hasSplatMesh = false;
let hasForgeRenderer = false;
let forgeRendererInstance;
const sceneAdd = THREE.Scene.prototype.add;
THREE.Scene.prototype.add = function(object) {
hasSplatMesh = hasSplatMesh || object instanceof SplatMesh;
hasSplatMesh = hasSplatMesh || hasSplatMeshInHierarchy(object);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove

hasForgeRenderer = hasForgeRenderer || object instanceof ForgeRenderer;
sceneAdd.call(this, object);
return this;
Expand Down
13 changes: 12 additions & 1 deletion src/ForgeRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ let hasForgeRenderer = false;

let forgeRendererInstance: ForgeRenderer;

// Helper function to check if a THREE.Object3D has a SplatMesh in its hierarchy
function hasSplatMeshInHierarchy(object: THREE.Object3D) {
let found = false;
object.traverse((child) => {
if (child instanceof SplatMesh) {
found = true;
}
});
return found;
}

const sceneAdd = THREE.Scene.prototype.add;
THREE.Scene.prototype.add = function (object) {
hasSplatMesh = hasSplatMesh || object instanceof SplatMesh;
hasSplatMesh = hasSplatMesh || hasSplatMeshInHierarchy(object);
hasForgeRenderer = hasForgeRenderer || object instanceof ForgeRenderer;
sceneAdd.call(this, object);
return this;
Expand Down